Loading nixos/modules/system/boot/stage-2-init.sh +0 −8 Original line number Diff line number Diff line Loading @@ -125,14 +125,6 @@ ln -sfn "$systemConfig" /run/booted-system @shell@ @postBootCommands@ # Ensure systemd doesn't try to populate /etc, by forcing its first-boot # heuristic off. It doesn't matter what's in /etc/machine-id for this purpose, # and systemd will immediately fill in the file when it starts, so just # creating it is enough. This `: >>` pattern avoids forking and avoids changing # the mtime if the file already exists. : >> /etc/machine-id # No need to restore the stdout/stderr streams we never redirected and # especially no need to start systemd if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" != true ]; then Loading nixos/modules/system/boot/systemd.nix +10 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ let "nss-lookup.target" "nss-user-lookup.target" "time-sync.target" "first-boot-complete.target" ] ++ optionals cfg.package.withCryptsetup [ "cryptsetup.target" "cryptsetup-pre.target" Loading Loading @@ -568,6 +569,15 @@ in "systemd/user-generators" = { source = hooks "user-generators" cfg.user.generators; }; "systemd/system-generators" = { source = hooks "system-generators" cfg.generators; }; "systemd/system-shutdown" = { source = hooks "system-shutdown" cfg.shutdown; }; # Ignore all other preset files so systemd doesn't try to enable/disable # units during runtime. "systemd/system-preset/00-nixos.preset".text = '' ignore * ''; "systemd/user-preset/00-nixos.preset".text = '' ignore * ''; }); services.dbus.enable = true; Loading nixos/tests/systemd.nix +12 −1 Original line number Diff line number Diff line Loading @@ -75,12 +75,19 @@ import ./make-test-python.nix ({ pkgs, ... }: { rebootTime = "10min"; kexecTime = "5min"; }; environment.etc."systemd/system-preset/10-testservice.preset".text = '' disable ${config.systemd.services.testservice1.name} ''; }; testScript = '' testScript = { nodes, ... }: '' import re import subprocess # Will not succeed unless ConditionFirstBoot=yes machine.wait_for_unit("first-boot-complete.target") machine.wait_for_x() # wait for user services machine.wait_for_unit("default.target", "alice") Loading Loading @@ -209,5 +216,9 @@ import ./make-test-python.nix ({ pkgs, ... }: { with subtest("systemd environment is properly set"): machine.systemctl("daemon-reexec") # Rewrites /proc/1/environ machine.succeed("grep -q TZDIR=/etc/zoneinfo /proc/1/environ") with subtest("systemd presets are ignored"): machine.succeed("systemctl preset ${nodes.machine.systemd.services.testservice1.name}") machine.succeed("test -e /etc/systemd/system/${nodes.machine.systemd.services.testservice1.name}") ''; }) Loading
nixos/modules/system/boot/stage-2-init.sh +0 −8 Original line number Diff line number Diff line Loading @@ -125,14 +125,6 @@ ln -sfn "$systemConfig" /run/booted-system @shell@ @postBootCommands@ # Ensure systemd doesn't try to populate /etc, by forcing its first-boot # heuristic off. It doesn't matter what's in /etc/machine-id for this purpose, # and systemd will immediately fill in the file when it starts, so just # creating it is enough. This `: >>` pattern avoids forking and avoids changing # the mtime if the file already exists. : >> /etc/machine-id # No need to restore the stdout/stderr streams we never redirected and # especially no need to start systemd if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" != true ]; then Loading
nixos/modules/system/boot/systemd.nix +10 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ let "nss-lookup.target" "nss-user-lookup.target" "time-sync.target" "first-boot-complete.target" ] ++ optionals cfg.package.withCryptsetup [ "cryptsetup.target" "cryptsetup-pre.target" Loading Loading @@ -568,6 +569,15 @@ in "systemd/user-generators" = { source = hooks "user-generators" cfg.user.generators; }; "systemd/system-generators" = { source = hooks "system-generators" cfg.generators; }; "systemd/system-shutdown" = { source = hooks "system-shutdown" cfg.shutdown; }; # Ignore all other preset files so systemd doesn't try to enable/disable # units during runtime. "systemd/system-preset/00-nixos.preset".text = '' ignore * ''; "systemd/user-preset/00-nixos.preset".text = '' ignore * ''; }); services.dbus.enable = true; Loading
nixos/tests/systemd.nix +12 −1 Original line number Diff line number Diff line Loading @@ -75,12 +75,19 @@ import ./make-test-python.nix ({ pkgs, ... }: { rebootTime = "10min"; kexecTime = "5min"; }; environment.etc."systemd/system-preset/10-testservice.preset".text = '' disable ${config.systemd.services.testservice1.name} ''; }; testScript = '' testScript = { nodes, ... }: '' import re import subprocess # Will not succeed unless ConditionFirstBoot=yes machine.wait_for_unit("first-boot-complete.target") machine.wait_for_x() # wait for user services machine.wait_for_unit("default.target", "alice") Loading Loading @@ -209,5 +216,9 @@ import ./make-test-python.nix ({ pkgs, ... }: { with subtest("systemd environment is properly set"): machine.systemctl("daemon-reexec") # Rewrites /proc/1/environ machine.succeed("grep -q TZDIR=/etc/zoneinfo /proc/1/environ") with subtest("systemd presets are ignored"): machine.succeed("systemctl preset ${nodes.machine.systemd.services.testservice1.name}") machine.succeed("test -e /etc/systemd/system/${nodes.machine.systemd.services.testservice1.name}") ''; })