addNuGetDeps: move TMPDIR handling out of fetch-deps

We now handle creating TMPDIR and setting the working directory outide
of nix-shell.  This allows nix-shell to set NIX_BUILD_TOP correctly.
This commit is contained in:
David McFarland 2024-09-08 21:34:04 -03:00
parent e7fb591c92
commit c693cb8ec6
2 changed files with 15 additions and 12 deletions

View File

@ -79,7 +79,12 @@ attrs
in
writeShellScript "${finalPackage.name}-fetch-deps" ''
NIX_BUILD_SHELL="${runtimeShell}" exec ${nix}/bin/nix-shell \
set -eu
export TMPDIR
TMPDIR=$(mktemp -d -t fetch-deps-${finalPackage.name}.XXXXXX)
trap 'chmod -R +w "$TMPDIR" && rm -fr "$TMPDIR"' EXIT
cd "$TMPDIR"
NIX_BUILD_SHELL="${runtimeShell}" {nix}/bin/nix-shell \
--pure --run 'source "${innerScript}"' "${drv}"
'';
};

View File

@ -1,20 +1,18 @@
set -e
tmp=$(mktemp -d)
trap 'chmod -R +w "$tmp" && rm -fr "$tmp"' EXIT
HOME=$tmp/.home
export TMPDIR="$tmp/.tmp"
mkdir "$HOME" "$TMPDIR"
cd "$tmp"
HOME=$NIX_BUILD_TOP/home
mkdir "$HOME"
export NIX_SSL_CERT_FILE=@cacert@/etc/ssl/certs/ca-bundle.crt
genericBuild
depsFile=$(realpath "${1:-@defaultDepsFile@}")
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"
@nugetToNix@/bin/nuget-to-nix "${NUGET_PACKAGES%/}" >> "$tmpFile"
mv "$tmpFile" "$depsFile"
(
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"