From a5ad8b4f69d541f1b8e456eb5d405b1558df9885 Mon Sep 17 00:00:00 2001 From: Jörg Thalheim Date: Tue, 4 Apr 2017 22:50:48 +0200 Subject: stage-2: simplify exporting path --- nixos/modules/system/boot/stage-2-init.sh | 17 +---------------- nixos/modules/system/boot/stage-2.nix | 10 +++++----- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh index f827e530f87..99930fb95a6 100644 --- a/nixos/modules/system/boot/stage-2-init.sh +++ b/nixos/modules/system/boot/stage-2-init.sh @@ -2,7 +2,7 @@ systemConfig=@systemConfig@ -export HOME=/root +export HOME=/root PATH="@path@" # Print a greeting. @@ -11,21 +11,6 @@ echo -e "\e[1;32m<<< NixOS Stage 2 >>>\e[0m" echo -# Set the PATH. -setPath() { - local dirs="$1" - export PATH=/empty - for i in $dirs; do - PATH=$PATH:$i/bin - if test -e $i/sbin; then - PATH=$PATH:$i/sbin - fi - done -} - -setPath "@path@" - - # Normally, stage 1 mounts the root filesystem read/writable. # However, in some environments, stage 2 is executed directly, and the # root is read-only. So make it writable here. diff --git a/nixos/modules/system/boot/stage-2.nix b/nixos/modules/system/boot/stage-2.nix index 7e4ec2a4a67..a6864bf80c3 100644 --- a/nixos/modules/system/boot/stage-2.nix +++ b/nixos/modules/system/boot/stage-2.nix @@ -23,11 +23,11 @@ let inherit (config.nix) readOnlyStore; inherit (config.networking) useHostResolvConf; inherit (config.system.build) earlyMountScript; - path = - [ pkgs.coreutils - pkgs.utillinux - pkgs.openresolv - ] ++ optional config.nix.readOnlyStore readonlyMountpoint; + path = lib.makeBinPath ([ + pkgs.coreutils + pkgs.utillinux + pkgs.openresolv + ] ++ optional config.nix.readOnlyStore readonlyMountpoint); postBootCommands = pkgs.writeText "local-cmds" '' ${config.boot.postBootCommands} -- cgit 1.4.1