nixos/activation/bootspec: embed the entire contents of specialisation's bootspecs into the parent

See: https://github.com/NixOS/rfcs/pull/125#discussion_r871222614
This commit is contained in:
Graham Christensen 2022-05-16 16:14:08 -04:00 committed by Cole Helbling
parent 83d06ce16d
commit 6c0e4e892f

View file

@ -19,25 +19,29 @@ let
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})";
specialisation = lib.mapAttrs
(childName: childToplevel: {
bootspec = "${childToplevel}/${filename}";
})
children;
});
generator = ''
${pkgs.jq}/bin/jq '
.toplevel = $toplevel |
.init = $init
' \
--sort-keys \
--arg toplevel "$out" \
--arg init "$out/init" \
< ${json} \
> $out/${filename}
'';
generator =
let
specialisationLoader = (lib.mapAttrsToList
(childName: childToplevel: lib.escapeShellArgs [ "--slurpfile" childName "${childToplevel}/${filename}" ])
children);
in
''
${pkgs.jq}/bin/jq '
.toplevel = $toplevel |
.init = $init
' \
--sort-keys \
--arg toplevel "$out" \
--arg init "$out/init" \
< ${json} \
| ${pkgs.jq}/bin/jq \
--sort-keys \
'.specialisation = ($ARGS.named | map_values(. | first))' \
${lib.concatStringsSep " " specialisationLoader} \
> $out/${filename}
'';
};
};
in