mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-15 14:09:17 +03:00
Merge pull request #207163 from NixOS/rfc0125-improvements
nixos/activation/bootspec: make initrd optional, serialize system, precise extensions' type
This commit is contained in:
commit
e2e8dfcf44
3 changed files with 32 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
#V1: {
|
#V1: {
|
||||||
|
system: string
|
||||||
init: string
|
init: string
|
||||||
initrd?: string
|
initrd?: string
|
||||||
initrdSecrets?: string
|
initrdSecrets?: string
|
||||||
|
|
|
@ -19,13 +19,15 @@ let
|
||||||
(builtins.toJSON
|
(builtins.toJSON
|
||||||
{
|
{
|
||||||
v1 = {
|
v1 = {
|
||||||
|
system = config.boot.kernelPackages.stdenv.hostPlatform.system;
|
||||||
kernel = "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}";
|
kernel = "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}";
|
||||||
kernelParams = config.boot.kernelParams;
|
kernelParams = config.boot.kernelParams;
|
||||||
initrd = "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}";
|
|
||||||
initrdSecrets = "${config.system.build.initialRamdiskSecretAppender}/bin/append-initrd-secrets";
|
|
||||||
label = "NixOS ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})";
|
label = "NixOS ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})";
|
||||||
|
|
||||||
inherit (cfg) extensions;
|
inherit (cfg) extensions;
|
||||||
|
} // lib.optionalAttrs config.boot.initrd.enable {
|
||||||
|
initrd = "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}";
|
||||||
|
initrdSecrets = "${config.system.build.initialRamdiskSecretAppender}/bin/append-initrd-secrets";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ in
|
||||||
enable = lib.mkEnableOption (lib.mdDoc "Enable generation of RFC-0125 bootspec in $system/bootspec, e.g. /run/current-system/bootspec");
|
enable = lib.mkEnableOption (lib.mdDoc "Enable generation of RFC-0125 bootspec in $system/bootspec, e.g. /run/current-system/bootspec");
|
||||||
|
|
||||||
extensions = lib.mkOption {
|
extensions = lib.mkOption {
|
||||||
type = lib.types.attrs;
|
type = lib.types.attrsOf lib.types.attrs; # <namespace>: { ...namespace-specific fields }
|
||||||
default = { };
|
default = { };
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
User-defined data that extends the bootspec document.
|
User-defined data that extends the bootspec document.
|
||||||
|
|
|
@ -90,6 +90,32 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Check that initrd create corresponding entries in bootspec.
|
||||||
|
initrd = makeTest {
|
||||||
|
name = "bootspec-with-initrd";
|
||||||
|
meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
|
||||||
|
|
||||||
|
nodes.machine = {
|
||||||
|
imports = [ standard ];
|
||||||
|
environment.systemPackages = [ pkgs.jq ];
|
||||||
|
# It's probably the case, but we want to make it explicit here.
|
||||||
|
boot.initrd.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
import json
|
||||||
|
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
|
machine.succeed("test -e /run/current-system/bootspec/boot.json")
|
||||||
|
|
||||||
|
bootspec = json.loads(machine.succeed("jq -r '.v1' /run/current-system/bootspec/boot.json"))
|
||||||
|
|
||||||
|
assert all(key in bootspec for key in ('initrd', 'initrdSecrets')), "Bootspec should contain initrd or initrdSecrets field when initrd is enabled"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# Check that specialisations create corresponding entries in bootspec.
|
# Check that specialisations create corresponding entries in bootspec.
|
||||||
specialisation = makeTest {
|
specialisation = makeTest {
|
||||||
name = "bootspec-with-specialisation";
|
name = "bootspec-with-specialisation";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue