+30
-123
nixos/modules/installer/tools/nixos-install.sh
···-mkdir -m 0755 -p $mountPoint/dev $mountPoint/proc $mountPoint/sys $mountPoint/etc $mountPoint/run $mountPoint/home-for f in /etc/resolv.conf /etc/hosts; do rm -f $mountPoint/$f; [ -f "$f" ] && cp -Lf $f $mountPoint/etc/; done-for f in /etc/passwd /etc/group; do touch $mountPoint/$f; [ -f "$f" ] && mount --rbind -o ro $f $mountPoint/$f; done···binary_caches="$(@perl@/bin/perl -I @nix@/lib/perl5/site_perl/*/* -e 'use Nix::Config; Nix::Config::readConfig; print $Nix::Config::config{"binary-caches"};')"-if ! NIX_DB_DIR=$mountPoint/nix/var/nix/db nix-store --check-validity @nix@ 2> /dev/null; then+nix-build "${extraBuildFlags[@]}" --no-out-link -E "with import <nixpkgs> {}; runCommand \"closure\" { exportReferencesGraph = [ \"x\" (buildEnv { name = \"env\"; paths = [ ($1) stdenv ]; }) ]; } \"cp x \$out\""+# Create a temporary file ending in .closure (so nixos-prepare-root knows to --import it) to transport the store closure-srcs=$(nix-env "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "")+channel_root="$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "")"+@prepare_root@/bin/nixos-prepare-root $mountPoint $channel_root $system_root @nixClosure@ $system_closure $channel_closure+# nixos-prepare-root doesn't currently do anything with file ownership, so we set it up here instead
+105
nixos/modules/installer/tools/nixos-prepare-root.sh
···+# This script's goal is to perform all "static" setup of a filesystem structure from pre-built store paths. Everything+# in here should run in a non-root context and inside a Nix builder. It's designed primarily to be called from image-+# building scripts and from nixos-install, but because it makes very few assumptions about the context in which it runs,+mkdir -m 0755 -p $mountPoint/dev $mountPoint/proc $mountPoint/sys $mountPoint/etc $mountPoint/run $mountPoint/home+# We support closures both in the format produced by `nix-store --export` and by `exportReferencesGraph`,+# mostly because there doesn't seem to be a single format that can be produced outside of a nix build and+nix-env --option build-use-substitutes false "${extraBuildFlags[@]}" -p $mountPoint/nix/var/nix/profiles/per-user/root/channels --set "$channel" --quiet+# Mark the target as a NixOS installation, otherwise switch-to-configuration will chicken out.
+11
-2
nixos/modules/installer/tools/tools.nix
···············
+15
-3
nixos/tests/installer.nix
······+$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "boot-after-install" });···+# Check that the daemon works, and that non-root users can run builds (this will build a new profile generation through the daemon)···+$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "rebuild-switch" });···+$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", "boot-after-rebuild-switch" });
+3
-2
pkgs/tools/package-management/nix/default.nix
···-# 1.11.8 doesn't yet have the patch to work on LLVM 4, so we patch it for now. Take this out once-# we move to a higher version. I'd pull the specific patch from upstream but it doesn't apply cleanly.