diff --git a/.gitignore b/.gitignore index 4e82d27..bb80336 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,42 @@ -# Autosave files -*~ - -# build -[Oo]bj/ -[Bb]in/ -packages/ -TestResults/ - -# globs -Makefile.in -*.DS_Store -*.sln.cache -*.suo -*.cache -*.pidb -*.userprefs -*.usertasks -config.log -config.make -config.status -aclocal.m4 -install-sh -autom4te.cache/ -*.user -*.tar.gz -tarballs/ -test-results/ -Thumbs.db - -# Mac bundle stuff -*.dmg -*.app - -# resharper -*_Resharper.* -*.Resharper - -# dotCover -*.dotCover +# Autosave files +*~ + +# build +[Oo]bj/ +[Bb]in/ +packages/ +TestResults/ + +# globs +Makefile.in +*.DS_Store +*.sln.cache +*.suo +*.cache +*.pidb +*.userprefs +*.usertasks +config.log +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.user +*.tar.gz +tarballs/ +test-results/ +Thumbs.db + +# Mac bundle stuff +*.dmg +*.app + +# resharper +*_Resharper.* +*.Resharper + +# dotCover +*.dotCover + +result \ No newline at end of file diff --git a/0001-patch-csproj-to-find-the-openxml-dll.patch b/0001-patch-csproj-to-find-the-openxml-dll.patch new file mode 100644 index 0000000..444624a --- /dev/null +++ b/0001-patch-csproj-to-find-the-openxml-dll.patch @@ -0,0 +1,52 @@ +From 8c764df6ad27d08b207029879f63d59838c6b53d Mon Sep 17 00:00:00 2001 +From: Jappie Klooster +Date: Mon, 25 Jul 2022 13:36:18 +0200 +Subject: [PATCH] patch csproj to find the openxml dll + +--- + XlsxValidator.csproj | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/XlsxValidator.csproj b/XlsxValidator.csproj +index 06bba76..272b4b5 100644 +--- a/XlsxValidator.csproj ++++ b/XlsxValidator.csproj +@@ -53,7 +53,7 @@ + + + +- ..\packages\DocumentFormat.OpenXml\lib\net35\DocumentFormat.OpenXml.dll ++ lib\dotnet\DocumentFormat.OpenXml\net35\DocumentFormat.OpenXml.dll + True + True + +@@ -62,7 +62,7 @@ + + + +- ..\packages\DocumentFormat.OpenXml\lib\net40\DocumentFormat.OpenXml.dll ++ lib\dotnet\DocumentFormat.OpenXml\net40\DocumentFormat.OpenXml.dll + True + True + +@@ -71,7 +71,7 @@ + + + +- ..\packages\DocumentFormat.OpenXml\lib\net46\DocumentFormat.OpenXml.dll ++ lib\dotnet\DocumentFormat.OpenXml\net46\DocumentFormat.OpenXml.dll + True + True + +@@ -80,7 +80,7 @@ + + + +- ..\packages\DocumentFormat.OpenXml\lib\netstandard1.3\DocumentFormat.OpenXml.dll ++ lib\dotnet\DocumentFormat.OpenXml\netstandard1.3\DocumentFormat.OpenXml.dll + True + True + +-- +2.33.3 + diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..c92c165 --- /dev/null +++ b/default.nix @@ -0,0 +1,45 @@ +/* +some_program/default.nix +nix-build -E 'with import { }; callPackage ./default.nix { }' +*/ + +{ lib +, stdenv +, fetchFromGitHub +, fetchNuGet +, buildDotnetPackage +, dotnetPackages +, pkg-config +, callPackage +}: +let + openxml = callPackage ./nix/openxml.nix {}; +in +# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/dotnet/build-dotnet-package/default.nix +buildDotnetPackage rec { + pname = "xlsx-validator"; + baseName = pname; # workaround for "called without baseName" + version = "1.0"; + src = ./XlsxValidator; + projectFile = ["./XlsxValidator.csproj"]; + + patches = [ ./0001-patch-csproj-to-find-the-openxml-dll.patch]; + + + # we patch in the openxml ref by hand, + # nix doesn't appear to do depencencies yet + preBuild = '' + set -xe + cp -r ${openxml}/lib ./lib + ls + ls ./lib/dotnet/DocumentFormat.OpenXml + ''; + nativeBuildInputs = [ + pkg-config + ]; + meta = { + homepage = "some_homepage"; + description = "some_description"; + license = lib.licenses.mit; + }; +} diff --git a/nix/build.nix b/nix/build.nix new file mode 100644 index 0000000..e578e72 --- /dev/null +++ b/nix/build.nix @@ -0,0 +1,6 @@ +# convenience insta build script +let + pkgs = import ./pin.nix {}; +in +pkgs.callPackage ../default.nix {} +# pkgs.callPackage ./openxml.nix {} diff --git a/nix/openxml.nix b/nix/openxml.nix new file mode 100644 index 0000000..1f0efcb --- /dev/null +++ b/nix/openxml.nix @@ -0,0 +1,13 @@ +/* +get's openxml +*/ +{ fetchNuGet, +}: + +# https://www.nuget.org/packages/DocumentFormat.OpenXml +fetchNuGet { + pname = "DocumentFormat.OpenXml"; + version = "2.17.1"; + sha256 = "05fcyh53hz6m45pgq49lvgaz9a150hkgl66xx6i4inaax9kcpr46"; + outputFiles = [ "lib/*" ]; + } diff --git a/nix/pin.nix b/nix/pin.nix new file mode 100644 index 0000000..7a28f2d --- /dev/null +++ b/nix/pin.nix @@ -0,0 +1,6 @@ +import (builtins.fetchGit { + # Descriptive name to make the store path easier to identify + name = "nixos-pin-2022.05.07"; + url = "https://github.com/nixos/nixpkgs/"; + rev = "18854d7bbc472919eace2303779d1653a78bd63b"; + }) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..827b24f --- /dev/null +++ b/shell.nix @@ -0,0 +1,6 @@ +let + pkgs = import ./nix/pin.nix {}; +in +pkgs.mkShell { + buildInputs = [pkgs.dotnet-sdk]; +}