Commit 424bbc43 authored by David McFarland's avatar David McFarland
Browse files

addNuGetDeps: fix fetch-deps output path handling

parent 988b57fa
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@ attrs
            src = ./fetch-deps.sh;
            isExecutable = true;
            inherit cacert;
            nugetToNix = nuget-to-nix;
          };

          defaultDepsFile =
            # Wire in the depsFile such that running the script with no args
            # runs it agains the correct deps file by default.
@@ -76,8 +79,6 @@ attrs
              toString nugetDeps
            else
              ''$(mktemp -t "${finalAttrs.pname or finalPackage.name}-deps-XXXXXX.nix")'';
            nugetToNix = nuget-to-nix;
          };

        in
        writeShellScript "${finalPackage.name}-fetch-deps" ''
@@ -85,8 +86,12 @@ attrs

          echo 'fetching dependencies for' ${lib.escapeShellArg finalPackage.name} >&2

          # this needs to be before TMPDIR is changed, so the output isn't deleted
          # if it uses mktemp
          depsFile=$(realpath "''${1:-${lib.escapeShellArg defaultDepsFile}}")

          export TMPDIR
          TMPDIR=$(mktemp -d -t fetch-deps-${finalPackage.name}.XXXXXX)
          TMPDIR=$(mktemp -d -t fetch-deps-${lib.escapeShellArg finalPackage.name}.XXXXXX)
          trap 'chmod -R +w "$TMPDIR" && rm -fr "$TMPDIR"' EXIT

          export NUGET_HTTP_CACHE_PATH=''${NUGET_HTTP_CACHE_PATH-~/.local/share/NuGet/v3-cache}
@@ -96,8 +101,8 @@ attrs

          cd "$TMPDIR"

          NIX_BUILD_SHELL="${runtimeShell}" ${nix}/bin/nix-shell \
            --pure --keep NUGET_HTTP_CACHE_PATH --run 'source "${innerScript}"' "${drv}"
          NIX_BUILD_SHELL=${lib.escapeShellArg runtimeShell} ${nix}/bin/nix-shell \
            --pure --keep NUGET_HTTP_CACHE_PATH --run 'source '${lib.escapeShellArg innerScript}' '"''${depsFile@Q}" "${drv}"
        '';
    };
}
+2 −4
Original line number Diff line number Diff line
@@ -2,12 +2,10 @@ set -e

genericBuild

depsFile=$(realpath "${1:-@defaultDepsFile@}")

(
    echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n"
    @nugetToNix@/bin/nuget-to-nix "${NUGET_PACKAGES%/}"
) > deps.nix

mv deps.nix "$depsFile"
echo "Succesfully wrote lockfile to $depsFile"
mv deps.nix "$1"
echo "Succesfully wrote lockfile to $1"