Skip to content

Commit

Permalink
Merge pull request #1654 from cachix/reset-tmpdir
Browse files Browse the repository at this point in the history
devenv: override temp dirs after nix develop
  • Loading branch information
domenkozar authored Dec 30, 2024
2 parents 6964588 + b32703d commit 36df08e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/modules/top-level.nix
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,11 @@ in
# - free to create as an unprivileged user across OSes
default =
let
runtimeEnv = builtins.getEnv "DEVENV_RUNTIME";

hashedRoot = builtins.hashString "sha256" config.devenv.state;

# same length as git's abbreviated commit hashes
shortHash = builtins.substring 0 7 hashedRoot;
in
if runtimeEnv != ""
then runtimeEnv
else "${config.devenv.tmpdir}/devenv-${shortHash}";
"${config.devenv.tmpdir}/devenv-${shortHash}";
};

tmpdir = lib.mkOption {
Expand Down Expand Up @@ -268,6 +263,16 @@ in
enterShell = ''
export PS1="\[\e[0;34m\](devenv)\[\e[0m\] ''${PS1-}"
# override temp directories after "nix develop"
for var in TMP TMPDIR TEMP TEMPDIR; do
if [ -n "''${!var-}" ]; then
export "$var"=${config.devenv.tmpdir}
fi
done
if [ -n "''${NIX_BUILD_TOP-}" ]; then
unset NIX_BUILD_TOP
fi
# set path to locales on non-NixOS Linux hosts
${lib.optionalString (pkgs.stdenv.isLinux && (pkgs.glibcLocalesUtf8 != null)) ''
if [ -z "''${LOCALE_ARCHIVE-}" ]; then
Expand Down

0 comments on commit 36df08e

Please sign in to comment.