From 1b6f56f5b8042000a826ecba2ebe52a831e2df46 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Mon, 15 May 2017 19:22:44 +0200 Subject: [PATCH] environment: include /usr/sbin and /sbin in systemPath Don't extend initial PATH adding extra entries should be done through appending environment.systemPath or manually extending it with environment.extraInit or similar options. --- modules/environment/default.nix | 5 +++-- modules/programs/bash.nix | 2 +- modules/programs/fish.nix | 2 +- modules/programs/zsh/default.nix | 2 +- modules/system/activation-scripts.nix | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/environment/default.nix b/modules/environment/default.nix index f982b25..492ff0a 100644 --- a/modules/environment/default.nix +++ b/modules/environment/default.nix @@ -12,6 +12,7 @@ let aliasCommands = mapAttrsFlatten (n: v: ''alias ${n}="${v}"'') cfg.shellAliases; + makeDrvBinPath = concatMapStringsSep ":" (p: if isDerivation p then "${p}/bin" else p); in { options = { @@ -34,7 +35,7 @@ in { environment.systemPath = mkOption { type = types.loeOf types.str; description = "The set of paths that are added to PATH."; - apply = x: if isList x then makeBinPath x else x; + apply = x: if isList x then makeDrvBinPath x else x; }; environment.profiles = mkOption { @@ -112,7 +113,7 @@ in { config = { - environment.systemPath = cfg.profiles ++ [ "/usr/local" "/usr" "" ]; + environment.systemPath = [ (makeBinPath cfg.profiles) "/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" ]; environment.profiles = [ # Use user, default and system profiles. diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index abd2875..da79742 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -63,7 +63,7 @@ in if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi __ETC_BASHRC_SOURCED=1 - export PATH=${config.environment.systemPath}''${PATH:+:$PATH} + export PATH=${config.environment.systemPath} ${config.system.build.setEnvironment} ${config.system.build.setAliases} diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index ba0f67d..62cfd8b 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -123,7 +123,7 @@ in set fish_function_path $fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions - set PATH ${replaceStrings [":"] [" "] config.environment.systemPath} $PATH + set PATH ${replaceStrings [":"] [" "] config.environment.systemPath} ${config.system.build.setEnvironment} diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 8eec449..f330a5c 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -177,7 +177,7 @@ in setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK - export PATH=${config.environment.systemPath}''${PATH:+:$PATH} + export PATH=${config.environment.systemPath} ${config.system.build.setEnvironment} ${config.system.build.setAliases} diff --git a/modules/system/activation-scripts.nix b/modules/system/activation-scripts.nix index 069d8da..0f14e91 100644 --- a/modules/system/activation-scripts.nix +++ b/modules/system/activation-scripts.nix @@ -40,7 +40,7 @@ in #! ${stdenv.shell} set -e set -o pipefail - export PATH=${pkgs.coreutils}/bin:${config.environment.systemPath}:$PATH + export PATH=${pkgs.coreutils}/bin:${config.environment.systemPath} systemConfig=@out@ @@ -75,7 +75,7 @@ in #! ${stdenv.shell} set -e set -o pipefail - export PATH=${pkgs.coreutils}/bin:${config.environment.systemPath}:$PATH + export PATH=${pkgs.coreutils}/bin:${config.environment.systemPath} systemConfig=@out@