From 962f1c43991a0422877848c98caccd6833511193 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Mon, 25 Jul 2022 13:35:53 +0200 Subject: [PATCH 1/3] First step at nixification --- .gitignore | 82 +++++++++++++++++++++++++------------------------ default.nix | 43 ++++++++++++++++++++++++++ nix/build.nix | 6 ++++ nix/openxml.nix | 13 ++++++++ nix/pin.nix | 6 ++++ shell.nix | 6 ++++ 6 files changed, 116 insertions(+), 40 deletions(-) create mode 100644 default.nix create mode 100644 nix/build.nix create mode 100644 nix/openxml.nix create mode 100644 nix/pin.nix create mode 100644 shell.nix 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/default.nix b/default.nix new file mode 100644 index 0000000..445fcfa --- /dev/null +++ b/default.nix @@ -0,0 +1,43 @@ +/* +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"]; + + + # 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..66d1832 --- /dev/null +++ b/nix/openxml.nix @@ -0,0 +1,13 @@ +/* +get's openxml +*/ +{ fetchNuGet, +}: + +# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/dotnet/build-dotnet-package/default.nix +fetchNuGet { + pname = "DocumentFormat.OpenXml"; + version = "2.8.1"; + sha256 = "08r7farkimmr0r7vjkdmc6a6vdz33smfc2si8zs5kf85c7l9nc67"; + 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]; +} From 484b6cfcd0d5581a9ddf83bcd1dcac4c4979287b Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Mon, 25 Jul 2022 13:36:18 +0200 Subject: [PATCH 2/3] patch csproj to find the openxml dll Revert "patch csproj to find the openxml dll" This reverts commit 8c764df6ad27d08b207029879f63d59838c6b53d. extract the nix changes into a patch so we can upstream this shouldn't break the windows based builds, these paths should rarely change so it should be fine. --- ...patch-csproj-to-find-the-openxml-dll.patch | 52 +++++++++++++++++++ default.nix | 2 + 2 files changed, 54 insertions(+) create mode 100644 0001-patch-csproj-to-find-the-openxml-dll.patch 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 index 445fcfa..c92c165 100644 --- a/default.nix +++ b/default.nix @@ -23,6 +23,8 @@ buildDotnetPackage rec { 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 From cb6120df1ad6d32ebb80f9d8aceb228222a1333c Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Mon, 25 Jul 2022 14:00:02 +0200 Subject: [PATCH 3/3] upgrade to the latest openxml --- nix/openxml.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/openxml.nix b/nix/openxml.nix index 66d1832..1f0efcb 100644 --- a/nix/openxml.nix +++ b/nix/openxml.nix @@ -4,10 +4,10 @@ get's openxml { fetchNuGet, }: -# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/dotnet/build-dotnet-package/default.nix +# https://www.nuget.org/packages/DocumentFormat.OpenXml fetchNuGet { pname = "DocumentFormat.OpenXml"; - version = "2.8.1"; - sha256 = "08r7farkimmr0r7vjkdmc6a6vdz33smfc2si8zs5kf85c7l9nc67"; + version = "2.17.1"; + sha256 = "05fcyh53hz6m45pgq49lvgaz9a150hkgl66xx6i4inaax9kcpr46"; outputFiles = [ "lib/*" ]; }