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 in
writeShellScript "${finalPackage.name}-fetch-deps" '' 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}" --pure --run 'source "${innerScript}"' "${drv}"
''; '';
}; };

View File

@ -1,20 +1,18 @@
set -e set -e
tmp=$(mktemp -d) HOME=$NIX_BUILD_TOP/home
trap 'chmod -R +w "$tmp" && rm -fr "$tmp"' EXIT mkdir "$HOME"
HOME=$tmp/.home
export TMPDIR="$tmp/.tmp"
mkdir "$HOME" "$TMPDIR"
cd "$tmp"
export NIX_SSL_CERT_FILE=@cacert@/etc/ssl/certs/ca-bundle.crt export NIX_SSL_CERT_FILE=@cacert@/etc/ssl/certs/ca-bundle.crt
genericBuild genericBuild
depsFile=$(realpath "${1:-@defaultDepsFile@}") 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" echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n"
mv "$tmpFile" "$depsFile" @nugetToNix@/bin/nuget-to-nix "${NUGET_PACKAGES%/}"
) > deps.nix
mv deps.nix "$depsFile"
echo "Succesfully wrote lockfile to $depsFile" echo "Succesfully wrote lockfile to $depsFile"