From a98e52085584d806bd80ab203c7b75c4e361f522 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Fri, 6 Jan 2023 19:44:07 +0100 Subject: [PATCH] build-dotnet-module: avoid `/run/user` for downloading packages Inside `nix-shell`, `TMPDIR` (used by `mktemp`) is set to `/run/user/` 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. --- pkgs/build-support/dotnet/build-dotnet-module/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix index 7f05a3a4eecc..d7d6d68c6c53 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix @@ -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() {