build-dotnet-module: avoid /run/user for downloading packages

Inside `nix-shell`, `TMPDIR` (used by `mktemp`) is set to
`/run/user/<uid>` which is usually a tmpfs stored in RAM.

When fetching a large dotnet deps tree to this tmpdir from a
nix-shell (e.g. via `btcpayserver/update.sh`), this can easily exceed
system RAM and `fetch-deps` fails.

mktemp arg `-t` is deprecated and can be omitted.
This commit is contained in:
Erik Arvstedt 2023-01-06 19:44:07 +01:00
parent c7e842df16
commit a98e520855
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -190,7 +190,13 @@ stdenvNoCC.mkDerivation (args // {
esac
done
export tmp=$(mktemp -td "${pname}-tmp-XXXXXX")
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=
fi
export tmp=$(mktemp -d "deps-${pname}-XXXXXX")
HOME=$tmp/home
exitTrap() {