diff --git a/modules/system/activation/switch-to-configuration.pl b/modules/system/activation/switch-to-configuration.pl index a5a06454006e..3db04727e528 100644 --- a/modules/system/activation/switch-to-configuration.pl +++ b/modules/system/activation/switch-to-configuration.pl @@ -4,8 +4,11 @@ use strict; use warnings; use File::Basename; use File::Slurp; +use Sys::Syslog qw(:standard :macros); use Cwd 'abs_path'; +my $out = "@out@"; + my $startListFile = "/run/systemd/start-list"; my $restartListFile = "/run/systemd/restart-list"; my $reloadListFile = "/run/systemd/reload-list"; @@ -25,15 +28,17 @@ EOF die "This is not a NixOS installation (/etc/NIXOS is missing)!\n" unless -f "/etc/NIXOS"; +openlog("nixos", "", LOG_USER); + # Install or update the bootloader. if ($action eq "switch" || $action eq "boot") { - system("@installBootLoader@ @out@") == 0 or exit 1; + system("@installBootLoader@ $out") == 0 or exit 1; exit 0 if $action eq "boot"; } # Check if we can activate the new configuration. my $oldVersion = read_file("/run/current-system/init-interface-version", err_mode => 'quiet') // ""; -my $newVersion = read_file("@out@/init-interface-version"); +my $newVersion = read_file("$out/init-interface-version"); if ($newVersion ne $oldVersion) { print STDERR <{$mountPoint}; my $new = $newFss->{$mountPoint}; @@ -276,7 +283,7 @@ print STDERR "NOT restarting the following units: ", join(", ", sort(@unitsToSki # and so on). my $res = 0; print STDERR "activating the configuration...\n"; -system("@out@/activate", "@out@") == 0 or $res = 2; +system("$out/activate", "$out") == 0 or $res = 2; # Restart systemd if necessary. if (abs_path("/proc/1/exe") ne abs_path("@systemd@/lib/systemd/systemd")) { @@ -342,4 +349,10 @@ if (scalar @failed > 0) { $res = 4; } +if ($res == 0) { + syslog(LOG_NOTICE, "finished switching to system configuration $out"); +} else { + syslog(LOG_ERR, "switching to system configuration $out failed (status $res)"); +} + exit $res; diff --git a/modules/system/boot/stage-2-init.sh b/modules/system/boot/stage-2-init.sh index e7c9e2b23d8e..e8b3a4030208 100644 --- a/modules/system/boot/stage-2-init.sh +++ b/modules/system/boot/stage-2-init.sh @@ -42,6 +42,9 @@ if [ ! -e /proc/1 ]; then fi +echo "booting system configuration $systemConfig" > /dev/kmsg + + # Make /nix/store a read-only bind mount to enforce immutability of # the Nix store. Note that we can't use "chown root:nixbld" here # because users/groups might not exist yet.