modules/image: distribute systemd-boot loader configs
This commit is contained in:
@@ -106,6 +106,7 @@ in
|
||||
dosfstools
|
||||
libfaketime
|
||||
mtools
|
||||
rsync
|
||||
];
|
||||
partitionID = vfatUuidFromFs bootFs;
|
||||
size = cfg.bootPartSize;
|
||||
@@ -124,7 +125,7 @@ in
|
||||
echo "installing extraBootFiles"
|
||||
for d in ${lib.escapeShellArgs cfg.extraBootFiles}; do
|
||||
echo "installing '$d'"
|
||||
cp -R $d/* ./
|
||||
rsync -arv $d/ ./
|
||||
done
|
||||
echo "copied extraBootFiles"
|
||||
)
|
||||
@@ -382,11 +383,50 @@ in
|
||||
''
|
||||
);
|
||||
|
||||
# TODO: generalize this beyond just `generic-extlinux-compatible`. use `system.build.installBootLoader`?
|
||||
sane.image.extraBootFiles = lib.optionals config.boot.loader.generic-extlinux-compatible.enable [
|
||||
(pkgs.runCommandLocal "populate-extlinux" {} ''
|
||||
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d "$out"
|
||||
'')
|
||||
];
|
||||
sane.image.extraBootFiles =
|
||||
lib.optionals config.boot.loader.generic-extlinux-compatible.enable [
|
||||
(pkgs.runCommandLocal "populate-extlinux" {} ''
|
||||
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d "$out"
|
||||
'')
|
||||
]
|
||||
++
|
||||
lib.optionals config.boot.loader.systemd-boot.enable [
|
||||
# it'd be cool to use `config.system.build.installBootLoader` to install both the bootloader config AND the bootloader itself,
|
||||
# but the combination of custom nixpkgs logic + systemd's sanity checking makes it near impossible to use
|
||||
# outside a live system.
|
||||
# so manually generate a bootloader entry:
|
||||
(pkgs.runCommandLocal "populate-systemd-boot" {} ''
|
||||
toplevel=${config.system.build.toplevel}
|
||||
kernel_params=$(cat "$toplevel/kernel-params")
|
||||
|
||||
kernel=$(readlink "$toplevel/kernel")
|
||||
kernel_name="''${kernel/\/nix\/store\//}"
|
||||
kernel_name="''${kernel_name/\//-}"
|
||||
efi_kernel="/EFI/nixos/$kernel_name.efi"
|
||||
install -Dm644 "$kernel" "$out/$efi_kernel"
|
||||
|
||||
initrd=$(readlink "$toplevel/initrd")
|
||||
initrd_name="''${initrd/\/nix\/store\//}"
|
||||
initrd_name="''${initrd_name/\//-}"
|
||||
efi_initrd="/EFI/nixos/$initrd_name.efi"
|
||||
install -Dm644 "$initrd" "$out/$efi_initrd"
|
||||
|
||||
mkdir -p $out/loader/entries
|
||||
cat > $out/loader/entries/nixos-generation-0.conf <<EOF
|
||||
title NixOS
|
||||
sort-key nixos
|
||||
version Generation 0 NixOS
|
||||
linux $efi_kernel
|
||||
initrd $initrd
|
||||
options init=$toplevel/init $kernel_params
|
||||
EOF
|
||||
cat > $out/loader/loader.conf <<EOF
|
||||
timeout 5
|
||||
default nixos-generation-0.conf
|
||||
console-mode keep
|
||||
EOF
|
||||
'')
|
||||
]
|
||||
;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user