Use multiple initrds to reduce rebuilds
This commit is contained in:
parent
4bd4603382
commit
8441f4372d
53
quickly.nix
53
quickly.nix
@ -9,18 +9,6 @@ let
|
|||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
|
||||||
|
|
||||||
netboot.storeContents = mkOption {
|
|
||||||
example = literalExample "[ pkgs.stdenv ]";
|
|
||||||
description = ''
|
|
||||||
This option lists additional derivations to be included in the
|
|
||||||
Nix store in the generated netboot image.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
# Don't build the GRUB menu builder script, since we don't need it
|
# Don't build the GRUB menu builder script, since we don't need it
|
||||||
# here and it causes a cyclic dependency.
|
# here and it causes a cyclic dependency.
|
||||||
@ -77,31 +65,26 @@ in
|
|||||||
boot.initrd.availableKernelModules = [ "squashfs" "overlay" ];
|
boot.initrd.availableKernelModules = [ "squashfs" "overlay" ];
|
||||||
boot.initrd.kernelModules = [ "loop" "overlay" ];
|
boot.initrd.kernelModules = [ "loop" "overlay" ];
|
||||||
|
|
||||||
# Closures to be copied to the Nix store, namely the init
|
|
||||||
# script and the top-level system configuration directory.
|
|
||||||
netboot.storeContents =
|
|
||||||
[ config.system.build.toplevel ];
|
|
||||||
|
|
||||||
# Create the squashfs image that contains the Nix store.
|
# Create the squashfs image that contains the Nix store.
|
||||||
system.build.squashfsStore = netbootpkgs.makeSquashfsManifest {
|
system.build.squashfsStore = netbootpkgs.makeSquashfsManifest {
|
||||||
name = "iso-manifeiist";
|
name = "iso-manifest";
|
||||||
storeContents = config.netboot.storeContents;
|
storeContents = config.system.build.toplevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Create the initrd
|
system.build.ipxeBootDir = netbootpkgs.makePxeScript {
|
||||||
system.build.netbootRamdisk = pkgs.makeInitrd {
|
inherit config pkgs;
|
||||||
inherit (config.boot.initrd) compressor;
|
initrds = {
|
||||||
prepend = [
|
initrd = "${config.system.build.initialRamdisk}/initrd";
|
||||||
"${config.system.build.initialRamdisk}/initrd"
|
squashes = "${(
|
||||||
"${(
|
|
||||||
netbootpkgs.makeCpioRecursive {
|
netbootpkgs.makeCpioRecursive {
|
||||||
name = "better-initrd";
|
name = "better-initrd";
|
||||||
inherit (config.boot.initrd) compressor;
|
inherit (config.boot.initrd) compressor;
|
||||||
root = config.system.build.squashfsStore;
|
root = config.system.build.squashfsStore;
|
||||||
}
|
}
|
||||||
)}/initrd"
|
)}/initrd";
|
||||||
];
|
squashmanifest = "${pkgs.makeInitrd {
|
||||||
|
inherit (config.boot.initrd) compressor;
|
||||||
contents =
|
contents =
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -111,22 +94,8 @@ in
|
|||||||
symlink = "/nix-store-isos";
|
symlink = "/nix-store-isos";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
}}/initrd";
|
||||||
};
|
};
|
||||||
|
|
||||||
system.build.netbootIpxeScript = pkgs.writeTextDir "netboot.ipxe" ''
|
|
||||||
#!ipxe
|
|
||||||
kernel ${pkgs.stdenv.hostPlatform.platform.kernelTarget} init=${config.system.build.toplevel}/init initrd=initrd ${toString config.boot.kernelParams}
|
|
||||||
initrd initrd
|
|
||||||
boot
|
|
||||||
'';
|
|
||||||
|
|
||||||
system.build.ipxeBootDir = pkgs.symlinkJoin {
|
|
||||||
name = "ipxeBootDir";
|
|
||||||
paths = [
|
|
||||||
config.system.build.netbootRamdisk
|
|
||||||
config.system.build.kernel
|
|
||||||
config.system.build.netbootIpxeScript
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.loader.timeout = 10;
|
boot.loader.timeout = 10;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user