1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-08-17 00:20:44 +03:00

environment: Rework test to assert against full $PATH

It’s deterministic after all, so test against the full thing for greater
flexibility in testing and confidence in lack of unexpected changes to
previously-untested parts of the default $PATH.

Do this in a subshell to avoid polluting the test script’s environment.
This commit is contained in:
Andrew Marshall 2024-05-22 13:34:01 -04:00
parent eac4f25028
commit 9b6f77200f

View File

@ -4,10 +4,18 @@ with lib;
{
test = ''
echo checking /run/current-system/sw/bin in environment >&2
grep 'export PATH=.*:/run/current-system/sw/bin' ${config.system.build.setEnvironment}
echo 'checking PATH' >&2
env_path=$(bash -c 'source ${config.system.build.setEnvironment}; echo $PATH')
echo checking /bin and /sbin in environment >&2
grep 'export PATH=.*:/usr/bin:/usr/sbin:/bin:/sbin' ${config.system.build.setEnvironment}
test "$env_path" = "${builtins.concatStringsSep ":" [
"/homeless-shelter/.nix-profile/bin"
"/run/current-system/sw/bin"
"/nix/var/nix/profiles/default/bin"
"/usr/local/bin"
"/usr/bin"
"/usr/sbin"
"/bin"
"/sbin"
]}"
'';
}