mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
nixos/activation-script: Make installBootLoader
default a script (#353543)
This commit is contained in:
commit
ff7d68490a
@ -205,10 +205,14 @@ in
|
||||
|
||||
system.build.installBootLoader = mkOption {
|
||||
internal = true;
|
||||
# "; true" => make the `$out` argument from switch-to-configuration.pl
|
||||
# go to `true` instead of `echo`, hiding the useless path
|
||||
# from the log.
|
||||
default = "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true";
|
||||
default = pkgs.writeShellScript "no-bootloader" ''
|
||||
echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2
|
||||
'';
|
||||
defaultText = lib.literalExpression ''
|
||||
pkgs.writeShellScript "no-bootloader" '''
|
||||
echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2
|
||||
'''
|
||||
'';
|
||||
description = ''
|
||||
A program that writes a bootloader installation script to the path passed in the first command line argument.
|
||||
|
||||
|
@ -53,11 +53,8 @@ in {
|
||||
environment.systemPackages = [ pkgs.socat ]; # for the socket activation stuff
|
||||
users.mutableUsers = false;
|
||||
|
||||
# For boot/switch testing
|
||||
system.build.installBootLoader = lib.mkForce (pkgs.writeShellScript "install-dummy-loader" ''
|
||||
echo "installing dummy bootloader"
|
||||
touch /tmp/bootloader-installed
|
||||
'');
|
||||
# Test that no boot loader still switches, e.g. in the ISO
|
||||
boot.loader.grub.enable = false;
|
||||
|
||||
specialisation = rec {
|
||||
brokenInitInterface.configuration.config.system.extraSystemBuilderCmds = ''
|
||||
@ -596,6 +593,19 @@ in {
|
||||
imports = [ slice.configuration ];
|
||||
systemd.slices.testslice.sliceConfig.MemoryMax = lib.mkForce null;
|
||||
};
|
||||
|
||||
dbusReload.configuration = { config, ... }: let
|
||||
dbusService = {
|
||||
"dbus" = "dbus";
|
||||
"broker" = "dbus-broker";
|
||||
}.${config.services.dbus.implementation};
|
||||
in {
|
||||
# We want to make sure that stc catches this as a reload,
|
||||
# not a restart.
|
||||
systemd.services.${dbusService}.restartTriggers = [
|
||||
(pkgs.writeText "dbus-reload-dummy" "dbus reload dummy")
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@ -672,22 +682,18 @@ in {
|
||||
"${stderrRunner} ${otherSystem}/bin/switch-to-configuration test"
|
||||
)
|
||||
|
||||
boot_loader_text = "Warning: do not know how to make this configuration bootable; please enable a boot loader."
|
||||
|
||||
with subtest("actions"):
|
||||
# boot action
|
||||
machine.fail("test -f /tmp/bootloader-installed")
|
||||
out = switch_to_specialisation("${machine}", "simpleService", action="boot")
|
||||
assert_contains(out, "installing dummy bootloader")
|
||||
assert_contains(out, boot_loader_text)
|
||||
assert_lacks(out, "activating the configuration...") # good indicator of a system activation
|
||||
machine.succeed("test -f /tmp/bootloader-installed")
|
||||
machine.succeed("rm /tmp/bootloader-installed")
|
||||
|
||||
# switch action
|
||||
machine.fail("test -f /tmp/bootloader-installed")
|
||||
out = switch_to_specialisation("${machine}", "", action="switch")
|
||||
assert_contains(out, "installing dummy bootloader")
|
||||
assert_contains(out, boot_loader_text)
|
||||
assert_contains(out, "activating the configuration...") # good indicator of a system activation
|
||||
machine.succeed("test -f /tmp/bootloader-installed")
|
||||
|
||||
# test and dry-activate actions are tested further down below
|
||||
|
||||
@ -749,7 +755,7 @@ in {
|
||||
out = switch_to_specialisation("${machine}", "")
|
||||
assert_contains(out, "stopping the following units: test.mount\n")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_contains(out, "reloading the following units: ${dbusService}\n")
|
||||
assert_lacks(out, "reloading the following units:")
|
||||
assert_lacks(out, "\nrestarting the following units:")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_lacks(out, "the following new units were started:")
|
||||
@ -757,7 +763,7 @@ in {
|
||||
out = switch_to_specialisation("${machine}", "storeMountModified")
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_contains(out, "NOT restarting the following changed units: -.mount")
|
||||
assert_contains(out, "reloading the following units: ${dbusService}\n")
|
||||
assert_lacks(out, "reloading the following units:")
|
||||
assert_lacks(out, "\nrestarting the following units:")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_lacks(out, "the following new units were started:")
|
||||
@ -768,7 +774,7 @@ in {
|
||||
out = switch_to_specialisation("${machine}", "swap")
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_contains(out, "reloading the following units: ${dbusService}\n")
|
||||
assert_lacks(out, "reloading the following units:")
|
||||
assert_lacks(out, "\nrestarting the following units:")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_contains(out, "the following new units were started: swapfile.swap")
|
||||
@ -777,7 +783,7 @@ in {
|
||||
assert_contains(out, "stopping swap device: /swapfile")
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_contains(out, "reloading the following units: ${dbusService}\n")
|
||||
assert_lacks(out, "reloading the following units:")
|
||||
assert_lacks(out, "\nrestarting the following units:")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_lacks(out, "the following new units were started:")
|
||||
@ -795,10 +801,10 @@ in {
|
||||
|
||||
# Start a simple service
|
||||
out = switch_to_specialisation("${machine}", "simpleService")
|
||||
assert_lacks(out, "installing dummy bootloader") # test does not install a bootloader
|
||||
assert_lacks(out, boot_loader_text) # test does not install a bootloader
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_contains(out, "reloading the following units: ${dbusService}\n") # huh
|
||||
assert_lacks(out, "reloading the following units:")
|
||||
assert_lacks(out, "\nrestarting the following units:")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_contains(out, "the following new units were started: test.service\n")
|
||||
@ -872,10 +878,10 @@ in {
|
||||
# Ensure the service can be started when the activation script isn't in toplevel
|
||||
# This is a lot like "Start a simple service", except activation-only deps could be gc-ed
|
||||
out = run_switch("${nodes.machine.specialisation.simpleServiceSeparateActivationScript.configuration.system.build.separateActivationScript}/bin/switch-to-configuration");
|
||||
assert_lacks(out, "installing dummy bootloader") # test does not install a bootloader
|
||||
assert_lacks(out, boot_loader_text) # test does not install a bootloader
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_contains(out, "reloading the following units: ${dbusService}\n") # huh
|
||||
assert_lacks(out, "reloading the following units:")
|
||||
assert_lacks(out, "\nrestarting the following units:")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_contains(out, "the following new units were started: test.service\n")
|
||||
@ -1429,5 +1435,15 @@ in {
|
||||
assert_lacks(out, "the following new units were started:")
|
||||
machine.succeed("systemctl start testservice.service")
|
||||
machine.succeed("echo 1 > /proc/sys/vm/panic_on_oom") # disallow OOMing
|
||||
|
||||
with subtest("dbus reloads"):
|
||||
out = switch_to_specialisation("${machine}", "")
|
||||
out = switch_to_specialisation("${machine}", "dbusReload")
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_contains(out, "reloading the following units: ${dbusService}\n")
|
||||
assert_lacks(out, "\nrestarting the following units:")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_lacks(out, "the following new units were started:")
|
||||
'';
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user