summary refs log tree commit diff
path: root/pkgs/build-support/dotnet
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/dotnet')
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/default.nix22
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh16
-rw-r--r--pkgs/build-support/dotnet/make-nuget-deps/default.nix6
-rwxr-xr-xpkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh1
4 files changed, 28 insertions, 17 deletions
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
index a9c49d1e526..686d89f8c11 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix
+++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
@@ -112,7 +112,11 @@ let
     if (nugetDeps != null) then
       if lib.isDerivation nugetDeps
       then nugetDeps
-      else mkNugetDeps { inherit name; nugetDeps = import nugetDeps; }
+      else mkNugetDeps {
+        inherit name;
+        nugetDeps = import nugetDeps;
+        sourceFile = nugetDeps;
+      }
     else throw "Defining the `nugetDeps` attribute is required, as to lock the NuGet dependencies. This file can be generated by running the `passthru.fetch-deps` script.";
 
   # contains the actual package dependencies
@@ -138,6 +142,8 @@ let
     name = "${name}-nuget-source";
     paths = [ dependenciesSource sdkSource ];
   };
+
+  nugetDepsFile = _nugetDeps.sourceFile;
 in
 stdenvNoCC.mkDerivation (args // {
   nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [
@@ -166,7 +172,7 @@ stdenvNoCC.mkDerivation (args // {
 
   passthru = {
     inherit nuget-source;
-
+  } // lib.optionalAttrs (nugetDepsFile != null) {
     fetch-deps =
       let
         flags = dotnetFlags ++ dotnetRestoreFlags;
@@ -180,8 +186,8 @@ stdenvNoCC.mkDerivation (args // {
           # Note that toString is necessary here as it results in the path at
           # eval time (i.e. to the file in your local Nixpkgs checkout) rather
           # than the Nix store path of the path after it's been imported.
-          if lib.isPath nugetDeps && !lib.hasPrefix "${builtins.storeDir}/" (toString nugetDeps)
-          then toString nugetDeps
+          if lib.isPath nugetDepsFile && !lib.hasPrefix "${builtins.storeDir}/" (toString nugetDepsFile)
+          then toString nugetDepsFile
           else ''$(mktemp -t "${pname}-deps-XXXXXX.nix")'';
       in
       writeShellScript "fetch-${pname}-deps" ''
@@ -208,7 +214,7 @@ stdenvNoCC.mkDerivation (args // {
         if [[ ''${TMPDIR:-} == /run/user/* ]]; then
            # /run/user is usually a tmpfs in RAM, which may be too small
            # to store all downloaded dotnet packages
-           TMPDIR=
+           unset TMPDIR
         fi
 
         export tmp=$(mktemp -td "deps-${pname}-XXXXXX")
@@ -281,13 +287,15 @@ stdenvNoCC.mkDerivation (args // {
         echo "Succesfully restored project"
 
         echo "Writing lockfile..."
-        echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$depsFile"
 
         excluded_sources="${lib.concatStringsSep " " sdkDeps}"
         for excluded_source in ''${excluded_sources[@]}; do
           ls "$excluded_source" >> "$tmp/excluded_list"
         done
-        nuget-to-nix "$tmp/nuget_pkgs" "$tmp/excluded_list" >> "$depsFile"
+        tmpFile="$tmp"/deps.nix
+        echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$tmpFile"
+        nuget-to-nix "$tmp/nuget_pkgs" "$tmp/excluded_list" >> "$tmpFile"
+        mv "$tmpFile" "$depsFile"
         echo "Succesfully wrote lockfile to $depsFile"
       '';
   } // args.passthru or { };
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
index 8035b42d086..3f2a89c4140 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
@@ -40,15 +40,15 @@ dotnetInstallHook() {
 
     dotnetPack() {
         local -r project="${1-}"
-         env dotnet pack ${project-} \
-             -p:ContinuousIntegrationBuild=true \
-             -p:Deterministic=true \
-             --output "$out/share" \
-             --configuration "@buildType@" \
-             --no-build \
+        env dotnet pack ${project-} \
+            -p:ContinuousIntegrationBuild=true \
+            -p:Deterministic=true \
+            --output "$out/share" \
+            --configuration "@buildType@" \
+            --no-build \
             --runtime "@runtimeId@" \
-             ${dotnetPackFlags[@]}  \
-             ${dotnetFlags[@]}
+            ${dotnetPackFlags[@]}  \
+            ${dotnetFlags[@]}
     }
 
     if (( "${#projectFile[@]}" == 0 )); then
diff --git a/pkgs/build-support/dotnet/make-nuget-deps/default.nix b/pkgs/build-support/dotnet/make-nuget-deps/default.nix
index 723646c5fdc..8281976df62 100644
--- a/pkgs/build-support/dotnet/make-nuget-deps/default.nix
+++ b/pkgs/build-support/dotnet/make-nuget-deps/default.nix
@@ -1,5 +1,5 @@
 { linkFarmFromDrvs, fetchurl }:
-{ name, nugetDeps }:
+{ name, nugetDeps, sourceFile ? null }:
 linkFarmFromDrvs "${name}-nuget-deps" (nugetDeps {
   fetchNuGet = { pname, version, sha256
     , url ? "https://www.nuget.org/api/v2/package/${pname}/${version}" }:
@@ -7,4 +7,6 @@ linkFarmFromDrvs "${name}-nuget-deps" (nugetDeps {
       name = "${pname}.${version}.nupkg";
       inherit url sha256;
     };
-})
+}) // {
+  inherit sourceFile;
+}
diff --git a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
index ce2a7070ea3..86bc4482088 100755
--- a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
+++ b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
@@ -1,6 +1,7 @@
 #!@runtimeShell@
 
 set -euo pipefail
+shopt -s nullglob
 
 export PATH="@binPath@"
 # used for glob ordering of package names