Skip to content

Commit

Permalink
[FEAT] Conditionally link devenv profile
Browse files Browse the repository at this point in the history
When loading a shell, devenv checks .devenv/profile is

1. not a link
2. readlink reports someplace other than ${profile}

Then will remove whatever is .devenv/profile and relink to the current
active profile. When running a single command at a time, this is
usually not a problem, but if you attempt to run two commands at the
same time, then the race condition of one process removing a link while
another is creating the link will emit warnings to stderr.
  • Loading branch information
penguincoder committed Oct 19, 2023
1 parent 5529446 commit 66ff9db
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/modules/top-level.nix
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ in
fi
mkdir -p .devenv
rm -f .devenv/profile
ln -s ${profile} .devenv/profile
if [ ! -L .devenv/profile ] || [ "$(${pkgs.coreutils}/bin/readlink .devenv/profile)" != "${profile}" ]
then
rm -f .devenv/profile
ln -nsf ${profile} .devenv/profile
fi
'';

shell = performAssertions (
Expand Down

0 comments on commit 66ff9db

Please sign in to comment.