2023-04-04 22:35:49 +00:00
|
|
|
{
|
2025-02-10 21:55:08 +00:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
2023-04-04 22:35:49 +00:00
|
|
|
}:
|
|
|
|
let
|
2025-02-10 21:55:08 +00:00
|
|
|
inherit (lib)
|
|
|
|
mkEnableOption
|
|
|
|
mkOption
|
|
|
|
mkIf
|
|
|
|
types
|
|
|
|
;
|
2024-06-29 21:59:27 +00:00
|
|
|
inherit (pkgs) runCommand;
|
2023-04-04 22:35:49 +00:00
|
|
|
in
|
|
|
|
{
|
2024-12-19 20:55:10 +00:00
|
|
|
imports = [ ./system-configuration.nix ];
|
2023-04-10 18:07:27 +00:00
|
|
|
options = {
|
|
|
|
boot.initramfs = {
|
2023-08-04 19:19:27 +00:00
|
|
|
enable = mkEnableOption "initramfs";
|
2023-04-10 18:07:27 +00:00
|
|
|
};
|
2023-10-30 21:23:50 +00:00
|
|
|
system.outputs = {
|
|
|
|
initramfs = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
internal = true;
|
|
|
|
description = ''
|
|
|
|
Initramfs image capable of mounting the real root
|
|
|
|
filesystem
|
|
|
|
'';
|
|
|
|
};
|
2023-07-13 18:24:59 +00:00
|
|
|
};
|
2023-04-10 18:07:27 +00:00
|
|
|
};
|
|
|
|
config = mkIf config.boot.initramfs.enable {
|
2023-04-15 16:35:02 +00:00
|
|
|
kernel.config = {
|
|
|
|
BLK_DEV_INITRD = "y";
|
2023-07-13 18:24:59 +00:00
|
|
|
INITRAMFS_SOURCE = builtins.toJSON "${config.system.outputs.initramfs}";
|
2025-02-10 21:55:08 +00:00
|
|
|
# INITRAMFS_COMPRESSION_LZO = "y";
|
2023-04-15 16:35:02 +00:00
|
|
|
};
|
2023-04-04 22:35:49 +00:00
|
|
|
|
2023-07-13 18:24:59 +00:00
|
|
|
system.outputs = {
|
2023-04-04 22:35:49 +00:00
|
|
|
initramfs =
|
2025-02-10 21:55:08 +00:00
|
|
|
let
|
|
|
|
inherit (pkgs.pkgsBuildBuild) gen_init_cpio;
|
|
|
|
in
|
|
|
|
runCommand "initramfs.cpio" { } ''
|
2023-04-04 22:35:49 +00:00
|
|
|
cat << SPECIALS | ${gen_init_cpio}/bin/gen_init_cpio /dev/stdin > $out
|
|
|
|
dir /proc 0755 0 0
|
|
|
|
dir /dev 0755 0 0
|
2023-04-15 16:35:02 +00:00
|
|
|
nod /dev/console 0600 0 0 c 5 1
|
2023-04-04 22:35:49 +00:00
|
|
|
dir /target 0755 0 0
|
|
|
|
dir /target/persist 0755 0 0
|
|
|
|
dir /target/nix 0755 0 0
|
2023-04-15 16:35:02 +00:00
|
|
|
file /init ${pkgs.preinit}/bin/preinit 0755 0 0
|
2023-04-04 22:35:49 +00:00
|
|
|
SPECIALS
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|