1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

packaging-nix: work around direnv bug

Restore the TMP, TEMP, TMPDIR, TEMPDIR variables to their previous
values if `use flake` modified them in `.envrc`.

Signed-off-by: Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
This commit is contained in:
Philipp Jungkamp 2023-06-13 10:17:57 +02:00
parent 7742a5f5b8
commit 08b5620188

31
.envrc
View file

@ -1,7 +1,34 @@
export_or_unset()
{
local var=$1
if [ -z "${!var+x}" ]; then
return
fi
if [ -n "$2" ]; then
export $var="$2"
else
unset $var
fi
}
if direnv_version "2.30.0" \
&& has nix \
&& nix show-config experimental-features 2>/dev/null | grep -wqF flakes
then
watch_file ./packaging/nix/*.nix
use flake ./packaging/nix
local oldtmp="$TMP"
local oldtemp="$TEMP"
local oldtmpdir="$TMPDIR"
local oldtempdir="$TEMPDIR"
watch_file ./packaging/nix/*.nix
use flake ./packaging/nix
export_or_unset TMP "$oldtmp"
export_or_unset TEMP "$oldtemp"
export_or_unset TMPDIR "$oldtmpdir"
export_or_unset TEMPDIR "$oldtempdir"
fi