整理 system.initrd

This commit is contained in:
陈浩南 2023-09-02 15:07:16 +08:00
parent 72571d5d88
commit e1e88dfdba
5 changed files with 50 additions and 59 deletions

View File

@ -250,6 +250,11 @@
grub.installDevice = "/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0";
march = "sandybridge";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};
packages.packageSet = "server";
services =
@ -280,11 +285,6 @@
synapse-proxy."synapse.chn.moe" = {};
nebula = { enable = true; lighthouse = null; };
};
boot =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};})
];
"vps4" =
@ -315,6 +315,11 @@
grub.installDevice = "/dev/disk/by-path/pci-0000:00:04.0";
march = "znver3";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};
packages.packageSet = "server";
services =
@ -324,11 +329,6 @@
sops = { enable = true; keyPathPrefix = "/nix/persistent"; };
sshd.enable = true;
};
boot =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};})
];
"vps7" =
@ -359,6 +359,11 @@
grub.installDevice = "/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0";
march = "broadwell";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};
packages =
{
@ -376,11 +381,6 @@
misskey = { enable = true; hostname = "xn--s8w913fdga.chn.moe"; };
synapse.enable = true;
};
boot =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};})
];
"nas" =
@ -411,6 +411,11 @@
grub.installDevice = "/dev/disk/by-path/pci-0000:00:04.0";
march = "silvermont";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};
packages.packageSet = "server";
services =
@ -420,11 +425,6 @@
sops = { enable = true; keyPathPrefix = "/nix/persistent"; };
sshd.enable = true;
};
boot =
{
network.enable = true;
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
};
};})
];
"xmupc1" =

View File

@ -1,38 +0,0 @@
inputs:
{
options.nixos.boot = let inherit (inputs.lib) mkOption types; in
{
network.enable = mkOption { type = types.bool; default = false; };
sshd =
{
enable = mkOption { type = types.bool; default = false; };
hostKeys = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
};
};
config =
let
inherit (inputs.lib) mkMerge mkIf;
inherit (inputs.localLib) mkConditional attrsToList stripeTabs;
inherit (inputs.config.nixos) boot;
inherit (builtins) concatStringsSep map;
in mkMerge
[
# generic
{
boot =
{
initrd.systemd.enable = true;
};
}
# network
(
mkIf boot.network.enable
{ boot = { initrd.network.enable = true; kernelParams = [ "ip=dhcp" ]; }; }
)
# sshd
(
mkIf boot.sshd.enable
{ boot.initrd.network.ssh = { enable = true; hostKeys = boot.sshd.hostKeys; };}
)
];
}

View File

@ -30,6 +30,6 @@ inputs:
deploy-rs = { inherit (prev) deploy-rs; inherit ((topInputs.deploy-rs.overlay final prev).deploy-rs) lib; };
})
];})
./kernel ./hardware ./packages ./boot ./system ./virtualization ./services ./bugs ./users
./kernel ./hardware ./packages ./system ./virtualization ./services ./bugs ./users
];
}

View File

@ -5,6 +5,7 @@ inputs:
./nix.nix
./fileSystems.nix
./grub.nix
./initrd.nix
];
options.nixos.system = let inherit (inputs.lib) mkOption types; in
{

28
modules/system/initrd.nix Normal file
View File

@ -0,0 +1,28 @@
inputs:
{
options.nixos.system.initrd = let inherit (inputs.lib) mkOption types; in
{
network.enable = mkOption { type = types.bool; default = false; };
sshd =
{
enable = mkOption { type = types.bool; default = false; };
hostKeys = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
};
};
config =
let
inherit (inputs.config.nixos.system) initrd;
in { boot =
{
initrd =
{
systemd.enable = true;
network =
{
enable = initrd.network.enable;
ssh = { enable = true; hostKeys = initrd.sshd.hostKeys; };
};
};
kernelParams = if initrd.network.enable then [ "ip=dhcp" ] else [];
};};
}