diff options
author | Robin Gloster <mail@glob.in> | 2016-08-12 09:46:53 +0000 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2016-08-12 09:46:53 +0000 |
commit | b7787d932ec9cbd82ea6bc7c69d8df159b606fdc (patch) | |
tree | c4b6af2e6b49732ce5c6982cb8512ce9b7f1f34d /nixos/modules/installer/tools/nixos-install.sh | |
parent | bc025e83bd6c44df38851ef23da53359a0e62841 (diff) | |
parent | 532b2222965377e77ed884c463ee2751fb51dba3 (diff) | |
download | nixlib-b7787d932ec9cbd82ea6bc7c69d8df159b606fdc.tar nixlib-b7787d932ec9cbd82ea6bc7c69d8df159b606fdc.tar.gz nixlib-b7787d932ec9cbd82ea6bc7c69d8df159b606fdc.tar.bz2 nixlib-b7787d932ec9cbd82ea6bc7c69d8df159b606fdc.tar.lz nixlib-b7787d932ec9cbd82ea6bc7c69d8df159b606fdc.tar.xz nixlib-b7787d932ec9cbd82ea6bc7c69d8df159b606fdc.tar.zst nixlib-b7787d932ec9cbd82ea6bc7c69d8df159b606fdc.zip |
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
Diffstat (limited to 'nixos/modules/installer/tools/nixos-install.sh')
-rw-r--r-- | nixos/modules/installer/tools/nixos-install.sh | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh index 7962be137875..0247925f4144 100644 --- a/nixos/modules/installer/tools/nixos-install.sh +++ b/nixos/modules/installer/tools/nixos-install.sh @@ -24,6 +24,7 @@ fi # Parse the command line for the -I flag extraBuildFlags=() chrootCommand=(/run/current-system/sw/bin/bash) +bootLoader=1 while [ "$#" -gt 0 ]; do i="$1"; shift 1 @@ -40,6 +41,18 @@ while [ "$#" -gt 0 ]; do --root) mountPoint="$1"; shift 1 ;; + --closure) + closure="$1"; shift 1 + ;; + --no-channel-copy) + noChannelCopy=1 + ;; + --no-root-passwd) + noRootPasswd=1 + ;; + --no-bootloader) + bootLoader=0 + ;; --show-trace) extraBuildFlags+=("$i") ;; @@ -111,7 +124,7 @@ if test -z "$NIXOS_CONFIG"; then NIXOS_CONFIG=/etc/nixos/configuration.nix fi -if ! test -e "$mountPoint/$NIXOS_CONFIG"; then +if [ ! -e "$mountPoint/$NIXOS_CONFIG" ] && [ -z "$closure" ]; then echo "configuration file $mountPoint/$NIXOS_CONFIG doesn't exist" exit 1 fi @@ -162,7 +175,7 @@ if ! NIX_DB_DIR=$mountPoint/nix/var/nix/db nix-store --check-validity @nix@ 2> / for i in $(@perl@/bin/perl @pathsFromGraph@ @nixClosure@); do echo " $i" chattr -R -i $mountPoint/$i 2> /dev/null || true # clear immutable bit - rsync -a $i $mountPoint/nix/store/ + @rsync@/bin/rsync -a $i $mountPoint/nix/store/ done # Register the paths in the Nix closure as valid. This is necessary @@ -200,16 +213,22 @@ for i in /nix/var/nix/manifests/*.nixmanifest; do done -# Get the absolute path to the NixOS/Nixpkgs sources. -nixpkgs="$(readlink -f $(nix-instantiate --find-file nixpkgs))" +if [ -z "$closure" ]; then + # Get the absolute path to the NixOS/Nixpkgs sources. + nixpkgs="$(readlink -f $(nix-instantiate --find-file nixpkgs))" + nixEnvAction="-f <nixpkgs/nixos> --set -A system" +else + nixpkgs="" + nixEnvAction="--set $closure" +fi # Build the specified Nix expression in the target store and install # it into the system configuration profile. echo "building the system configuration..." NIX_PATH="nixpkgs=/tmp/root/$nixpkgs:nixos-config=$NIXOS_CONFIG" NIXOS_CONFIG= \ chroot $mountPoint @nix@/bin/nix-env \ - "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/system -f '<nixpkgs/nixos>' --set -A system + "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/system $nixEnvAction # Copy the NixOS/Nixpkgs sources to the target as the initial contents @@ -218,7 +237,7 @@ mkdir -m 0755 -p $mountPoint/nix/var/nix/profiles mkdir -m 1777 -p $mountPoint/nix/var/nix/profiles/per-user mkdir -m 0755 -p $mountPoint/nix/var/nix/profiles/per-user/root srcs=$(nix-env "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "") -if test -n "$srcs"; then +if [ -z "$noChannelCopy" ] && [ -n "$srcs" ]; then echo "copying NixOS/Nixpkgs sources..." chroot $mountPoint @nix@/bin/nix-env \ "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/per-user/root/channels -i "$srcs" --quiet @@ -244,7 +263,7 @@ touch $mountPoint/etc/NIXOS # a menu default pointing at the kernel/initrd/etc of the new # configuration. echo "finalising the installation..." -NIXOS_INSTALL_GRUB=1 chroot $mountPoint \ +NIXOS_INSTALL_GRUB="$bootLoader" chroot $mountPoint \ /nix/var/nix/profiles/system/bin/switch-to-configuration boot @@ -253,7 +272,7 @@ chroot $mountPoint /nix/var/nix/profiles/system/activate # Ask the user to set a root password. -if [ "$(chroot $mountPoint /run/current-system/sw/bin/sh -l -c "nix-instantiate --eval '<nixpkgs/nixos>' -A config.users.mutableUsers")" = true ] && [ -t 0 ] ; then +if [ -z "$noRootPasswd" ] && [ "$(chroot $mountPoint /run/current-system/sw/bin/sh -l -c "nix-instantiate --eval '<nixpkgs/nixos>' -A config.users.mutableUsers")" = true ] && [ -t 0 ] ; then echo "setting root password..." chroot $mountPoint /var/setuid-wrappers/passwd fi |