···519519520520- `services.gitea` now supports CAPTCHA usage through the `services.gitea.captcha` variable.
521521522522-- The GRUB bootloader (`boot.loader.grub`) now generates [boot loader entries](https://uapi-group.org/specifications/specs/boot_loader_specification/).
523523- These files are used by userspace tools (for example, `bootctl`) to inspect the bootloader status, getting the default boot entry, the path of the kernel binary, etc.
524524- As a consequence, `systemctl kexec` now works automatically: specifying the kernel and its arguments with `kexec --load` is no longer required.
525525-526522- `bind.cacheNetworks` now only controls access for recursive queries, where it previously controlled access for all queries.
527523528524- [`services.mongodb.enableAuth`](#opt-services.mongodb.enableAuth) now uses the newer [mongosh](https://github.com/mongodb-js/mongosh) shell instead of the legacy shell to configure the initial superuser. You can configure the mongosh package to use through the [`services.mongodb.mongoshPackage`](#opt-services.mongodb.mongoshPackage) option.
-14
nixos/modules/system/boot/loader/grub/grub.nix
···5050 then realGrub.override { efiSupport = cfg.efiSupport; }
5151 else null;
52525353- bootPath = if cfg.mirroredBoots != [ ]
5454- then (builtins.head cfg.mirroredBoots).path
5555- else "/boot";
5656-5753 f = x: optionalString (x != null) ("" + x);
58545955 grubConfig = args:
···759755 system.boot.loader.id = "grub";
760756761757 environment.systemPackages = mkIf (grub != null) [ grub ];
762762-763763- # Link /boot under /run/boot-loder-entries to make
764764- # systemd happy even on non-EFI system
765765- systemd.mounts = lib.optional (!cfg.efiSupport) {
766766- what = bootPath;
767767- where = "/run/boot-loader-entries";
768768- type = "none";
769769- options = "bind";
770770- requiredBy = [ "local-fs.target" ];
771771- };
772758773759 boot.loader.grub.extraPrepareConfig =
774760 concatStrings (mapAttrsToList (n: v: ''
···11-{ pkgs, runTest }:
22-33-{
44- # Basic GRUB setup with BIOS and a password
55- basic = runTest {
66- name = "grub-basic";
77- meta.maintainers = with pkgs.lib.maintainers; [ rnhmjoj ];
88-99- nodes.machine = { ... }: {
1010- virtualisation.useBootLoader = true;
1111- boot.loader.timeout = null;
1212- boot.loader.grub = {
1313- enable = true;
1414- users.alice.password = "supersecret";
1515- # OCR is not accurate enough
1616- extraConfig = "serial; terminal_output serial";
1717- };
1818- };
1919-2020- testScript = ''
2121- def grub_login_as(user, password):
2222- """
2323- Enters user and password to log into GRUB
2424- """
2525- machine.wait_for_console_text("Enter username:")
2626- machine.send_chars(user + "\n")
2727- machine.wait_for_console_text("Enter password:")
2828- machine.send_chars(password + "\n")
2929-3030-3131- def grub_select_all_configurations():
3232- """
3333- Selects "All configurations" from the GRUB menu
3434- to trigger a login request.
3535- """
3636- machine.send_monitor_command("sendkey down")
3737- machine.send_monitor_command("sendkey ret")
3838-3939-4040- machine.start()
11+import ./make-test-python.nix ({ lib, ... }: {
22+ name = "grub";
4134242- # wait for grub screen
4343- machine.wait_for_console_text("GNU GRUB")
44+ meta = with lib.maintainers; {
55+ maintainers = [ rnhmjoj ];
66+ };
4474545- grub_select_all_configurations()
4646- with subtest("Invalid credentials are rejected"):
4747- grub_login_as("wronguser", "wrongsecret")
4848- machine.wait_for_console_text("error: access denied.")
88+ nodes.machine = { ... }: {
99+ virtualisation.useBootLoader = true;
49105050- grub_select_all_configurations()
5151- with subtest("Valid credentials are accepted"):
5252- grub_login_as("alice", "supersecret")
5353- machine.send_chars("\n") # press enter to boot
5454- machine.wait_for_console_text("Linux version")
1111+ boot.loader.timeout = null;
1212+ boot.loader.grub = {
1313+ enable = true;
1414+ users.alice.password = "supersecret";
55155656- with subtest("Machine boots correctly"):
5757- machine.wait_for_unit("multi-user.target")
5858- '';
1616+ # OCR is not accurate enough
1717+ extraConfig = "serial; terminal_output serial";
5918 };
1919+ };
60206161- # Test boot loader entries on EFI
6262- bls-efi = runTest {
6363- name = "grub-bls-efi";
6464- meta.maintainers = with pkgs.lib.maintainers; [ rnhmjoj ];
2121+ testScript = ''
2222+ def grub_login_as(user, password):
2323+ """
2424+ Enters user and password to log into GRUB
2525+ """
2626+ machine.wait_for_console_text("Enter username:")
2727+ machine.send_chars(user + "\n")
2828+ machine.wait_for_console_text("Enter password:")
2929+ machine.send_chars(password + "\n")
65306666- nodes.machine = { pkgs, ... }: {
6767- virtualisation.useBootLoader = true;
6868- virtualisation.useEFIBoot = true;
6969- boot.loader.efi.canTouchEfiVariables = true;
7070- boot.loader.grub.enable = true;
7171- boot.loader.grub.efiSupport = true;
7272- };
73317474- testScript = ''
7575- with subtest("Machine boots correctly"):
7676- machine.wait_for_unit("multi-user.target")
3232+ def grub_select_all_configurations():
3333+ """
3434+ Selects "All configurations" from the GRUB menu
3535+ to trigger a login request.
3636+ """
3737+ machine.send_monitor_command("sendkey down")
3838+ machine.send_monitor_command("sendkey ret")
77397878- with subtest("Boot entries are installed"):
7979- entries = machine.succeed("bootctl list")
8080- print(entries)
8181- error = "NixOS boot entry not found in bootctl list."
8282- assert "version: Generation 1" in entries, error
83408484- with subtest("systemctl kexec can detect the kernel"):
8585- machine.succeed("systemctl kexec --dry-run")
4141+ machine.start()
86428787- with subtest("systemctl kexec really works"):
8888- machine.execute("systemctl kexec", check_return=False)
8989- machine.connected = False
9090- machine.connect()
9191- machine.wait_for_unit("multi-user.target")
9292- '';
9393- };
4343+ # wait for grub screen
4444+ machine.wait_for_console_text("GNU GRUB")
94459595- # Test boot loader entries on BIOS
9696- bls-bios = runTest {
9797- name = "grub-bls-bios";
9898- meta.maintainers = with pkgs.lib.maintainers; [ rnhmjoj ];
9999-100100- nodes.machine = { pkgs, ... }: {
101101- virtualisation.useBootLoader = true;
102102- boot.loader.grub.enable = true;
103103- };
104104-105105- testScript = ''
106106- with subtest("Machine boots correctly"):
107107- machine.wait_for_unit("multi-user.target")
108108-109109- with subtest("Boot entries are installed"):
110110- machine.succeed("test -f /boot/loader/entries/nixos-generation-1.conf")
111111-112112- with subtest("systemctl kexec can detect the kernel"):
113113- machine.succeed("systemctl kexec --dry-run")
4646+ grub_select_all_configurations()
4747+ with subtest("Invalid credentials are rejected"):
4848+ grub_login_as("wronguser", "wrongsecret")
4949+ machine.wait_for_console_text("error: access denied.")
11450115115- with subtest("systemctl kexec really works"):
116116- machine.execute("systemctl kexec", check_return=False)
117117- machine.connected = False
118118- machine.connect()
119119- machine.wait_for_unit("multi-user.target")
120120- '';
121121- };
5151+ grub_select_all_configurations()
5252+ with subtest("Valid credentials are accepted"):
5353+ grub_login_as("alice", "supersecret")
5454+ machine.send_chars("\n") # press enter to boot
5555+ machine.wait_for_console_text("Linux version")
12256123123-}
5757+ with subtest("Machine boots correctly"):
5858+ machine.wait_for_unit("multi-user.target")
5959+ '';
6060+})
-3
nixos/tests/nixos-rebuild-install-bootloader.nix
···7171 # at this point we've tested regression #262724, but haven't tested the bootloader itself
7272 # TODO: figure out how to how to tell the test driver to start the bootloader instead of
7373 # booting into the kernel directly.
7474-7575- with subtest("New boot entry has been added"):
7676- machine.succeed("test -f /boot/loader/entries/nixos-generation-2.conf")
7774 '';
7875})