server: switch to systemd initrd

This commit is contained in:
chayleaf 2024-07-13 06:05:08 +07:00
parent 5a3dda7a10
commit 2bdbbafbb0
Signed by: chayleaf
GPG key ID: 78171AD46227E68E
3 changed files with 46 additions and 15 deletions

View file

@ -629,11 +629,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1720722856, "lastModified": 1720888318,
"narHash": "sha256-vTD9PK8X0rVrOkcRetSpTacRNbH/qZi8YdKBXxAC8GQ=", "narHash": "sha256-s5Pf3Es1reWTvHiz0YNuVknH/0RGo2vu+8MyeKT7VWo=",
"owner": "chayleaf", "owner": "chayleaf",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "06bfe30652b5d4b56a800a09c29ada61adcede65", "rev": "81b52fd15be6a3331668cc7bbaab4aec7c654472",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -71,6 +71,7 @@
# mobile-nixos = true; # mobile-nixos = true;
# nixos-router = true; # nixos-router = true;
# notnft = true; # notnft = true;
# nixpkgs = true;
}; };
# IRL-related stuff I'd rather not put into git # IRL-related stuff I'd rather not put into git
priv = priv =

View file

@ -1,8 +1,9 @@
{ config { config
, lib , pkgs
, router-config , router-config
, hardware , hardware
, ... }: , ...
}:
let let
uuids.enc = "15945050-df48-418b-b736-827749b9262a"; uuids.enc = "15945050-df48-418b-b736-827749b9262a";
@ -60,16 +61,39 @@ in
}; };
boot.initrd = { boot.initrd = {
# eth0 on some kernels systemd = {
# end0 on other kernels services.unlock-bcachefs-persist.enable = false;
# sometimes even version dependent enable = true;
preLVMCommands = lib.mkOrder 499 '' network = {
ip link set end0 address ${router-config.router-settings.serverInitrdMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true enable = true;
''; links."10-mac" = {
network.enable = true; matchConfig.OriginalName = "e*";
linkConfig = {
MACAddressPolicy = "none";
MACAddress = router-config.router-settings.serverInitrdMac;
};
};
networks."10-dhcp" = {
DHCP = "yes";
name = "e*";
networkConfig = {
IPv6AcceptRA = "yes";
};
dhcpV4Config = {
ClientIdentifier = "mac";
DUIDType = "link-layer";
};
dhcpV6Config = {
DUIDType = "link-layer";
};
};
};
};
network.enable = false;
network.flushBeforeStage2 = true; network.flushBeforeStage2 = true;
network.udhcpc.enable = true; systemd.initrdBin = [ pkgs.iproute2 pkgs.vim pkgs.bashInteractive pkgs.util-linux ];
network.udhcpc.extraArgs = [ "-t100" ]; systemd.storePaths = [ pkgs.vim pkgs.busybox ];
systemd.users.root.shell = "/bin/bash";
network.ssh = { network.ssh = {
enable = true; enable = true;
port = 22; port = 22;
@ -102,7 +126,13 @@ in
options = [ "defaults" "size=2G" "mode=755" ]; }; options = [ "defaults" "size=2G" "mode=755" ]; };
"/persist" = "/persist" =
{ device = "UUID=${uuids.bch}"; fsType = "bcachefs"; inherit neededForBoot; { device = "UUID=${uuids.bch}"; fsType = "bcachefs"; inherit neededForBoot;
options = [ "errors=ro" ]; }; options = [
"errors=ro"
"x-systemd.device-timeout=0"
"x-systemd.requires=dev-mapper-bch0.device"
"x-systemd.requires=dev-mapper-bch1.device"
"x-systemd.requires=dev-mapper-bch2.device"
]; };
"/boot" = { device = parts.boot; fsType = "vfat"; inherit neededForBoot; }; "/boot" = { device = parts.boot; fsType = "vfat"; inherit neededForBoot; };
}; };