nix/modules/uki: use upstream systemdUkify

This commit is contained in:
nikstur 2024-03-10 19:00:42 +01:00
parent 3881267e84
commit e17ed9d6da
1 changed files with 30 additions and 38 deletions

View File

@ -17,46 +17,38 @@ in
}; };
}; };
config = config = lib.mkIf cfg.enable {
let boot.bootspec.enable = true;
systemdUkify = pkgs.systemdMinimal.override { boot.loader.external = {
withEfi = true; enable = true;
withBootloader = true; installHook =
withUkify = true; let
}; bootspecNamespace = ''"org.nixos.bootspec.v1"'';
in installer = pkgs.writeShellApplication {
lib.mkIf cfg.enable { name = "install-uki";
boot.bootspec.enable = true; runtimeInputs = with pkgs; [ jq systemd binutils ];
boot.loader.external = { text = ''
enable = true; boot_json=/nix/var/nix/profiles/system-1-link/boot.json
installHook = kernel=$(jq -r '.${bootspecNamespace}.kernel' "$boot_json")
let initrd=$(jq -r '.${bootspecNamespace}.initrd' "$boot_json")
bootspecNamespace = ''"org.nixos.bootspec.v1"''; init=$(jq -r '.${bootspecNamespace}.init' "$boot_json")
installer = pkgs.writeShellApplication {
name = "install-uki";
runtimeInputs = with pkgs; [ jq systemd binutils ];
text = ''
boot_json=/nix/var/nix/profiles/system-1-link/boot.json
kernel=$(jq -r '.${bootspecNamespace}.kernel' "$boot_json")
initrd=$(jq -r '.${bootspecNamespace}.initrd' "$boot_json")
init=$(jq -r '.${bootspecNamespace}.init' "$boot_json")
${systemdUkify}/lib/systemd/ukify \ ${pkgs.systemdUkify}/lib/systemd/ukify \
"$kernel" \ "$kernel" \
"$initrd" \ "$initrd" \
--stub=${cfg.stub} \ --stub=${cfg.stub} \
--cmdline="init=$init ${builtins.toString config.boot.kernelParams}" \ --cmdline="init=$init ${builtins.toString config.boot.kernelParams}" \
--os-release="@${config.system.build.etc}/etc/os-release" \ --os-release="@${config.system.build.etc}/etc/os-release" \
--output=uki.efi --output=uki.efi
esp=${config.boot.loader.efi.efiSysMountPoint} esp=${config.boot.loader.efi.efiSysMountPoint}
bootctl install --esp-path="$esp" bootctl install --esp-path="$esp"
install uki.efi "$esp"/EFI/Linux/ install uki.efi "$esp"/EFI/Linux/
''; '';
}; };
in in
"${installer}/bin/install-uki"; "${installer}/bin/install-uki";
};
}; };
};
} }