diff --git a/modules/environment/default.nix b/modules/environment/default.nix index 753ee311f..bb996222f 100644 --- a/modules/environment/default.nix +++ b/modules/environment/default.nix @@ -151,7 +151,10 @@ in config = { - environment.systemPath = [ (makeBinPath cfg.profiles) "/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" ]; + environment.systemPath = mkMerge [ + [ (makeBinPath cfg.profiles) ] + (mkOrder 1200 [ "/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" ]) + ]; # Use user, default and system profiles. environment.profiles = mkMerge [ diff --git a/tests/environment-path.nix b/tests/environment-path.nix index 7d2f46dd9..0bb9a0558 100644 --- a/tests/environment-path.nix +++ b/tests/environment-path.nix @@ -3,11 +3,37 @@ with lib; { + environment.systemPath = mkMerge [ + (mkBefore [ "beforePath" ]) + [ "myPath" ] + (mkAfter [ "afterPath" ]) + ]; + + environment.profiles = mkMerge [ + (mkBefore [ "beforeProfile" ]) + [ "myProfile" ] + (mkAfter [ "afterProfile" ]) + ]; + 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 ":" [ + "beforePath" + "myPath" + "beforeProfile/bin" + "/homeless-shelter/.nix-profile/bin" + "myProfile/bin" + "/run/current-system/sw/bin" + "/nix/var/nix/profiles/default/bin" + "afterProfile/bin" + "/usr/local/bin" + "/usr/bin" + "/usr/sbin" + "/bin" + "/sbin" + "afterPath" + ]}" ''; }