about summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2022-05-16 16:14:08 -0400
committerCole Helbling <cole.e.helbling@outlook.com>2022-12-08 13:50:04 -0800
commit6c0e4e892ff70b2875da3fd04e37b7fe3019850d (patch)
tree6f7e922f39bd6e17be529f0410586abb2453655e /nixos/modules/system
parent83d06ce16d3c0f8aa7fec4d6f8cf069c3b16205a (diff)
nixos/activation/bootspec: embed the entire contents of specialisation's bootspecs into the parent
See: https://github.com/NixOS/rfcs/pull/125#discussion_r871222614
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/activation/bootspec.nix38
1 files changed, 21 insertions, 17 deletions
diff --git a/nixos/modules/system/activation/bootspec.nix b/nixos/modules/system/activation/bootspec.nix
index c38f675cea27b..f14ec65137f3d 100644
--- a/nixos/modules/system/activation/bootspec.nix
+++ b/nixos/modules/system/activation/bootspec.nix
@@ -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