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": {
"locked": {
"lastModified": 1720722856,
"narHash": "sha256-vTD9PK8X0rVrOkcRetSpTacRNbH/qZi8YdKBXxAC8GQ=",
"lastModified": 1720888318,
"narHash": "sha256-s5Pf3Es1reWTvHiz0YNuVknH/0RGo2vu+8MyeKT7VWo=",
"owner": "chayleaf",
"repo": "nixpkgs",
"rev": "06bfe30652b5d4b56a800a09c29ada61adcede65",
"rev": "81b52fd15be6a3331668cc7bbaab4aec7c654472",
"type": "github"
},
"original": {

View file

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

View file

@ -1,8 +1,9 @@
{ config
, lib
, pkgs
, router-config
, hardware
, ... }:
, ...
}:
let
uuids.enc = "15945050-df48-418b-b736-827749b9262a";
@ -60,16 +61,39 @@ in
};
boot.initrd = {
# eth0 on some kernels
# end0 on other kernels
# sometimes even version dependent
preLVMCommands = lib.mkOrder 499 ''
ip link set end0 address ${router-config.router-settings.serverInitrdMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true
'';
network.enable = true;
systemd = {
services.unlock-bcachefs-persist.enable = false;
enable = true;
network = {
enable = true;
links."10-mac" = {
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.udhcpc.enable = true;
network.udhcpc.extraArgs = [ "-t100" ];
systemd.initrdBin = [ pkgs.iproute2 pkgs.vim pkgs.bashInteractive pkgs.util-linux ];
systemd.storePaths = [ pkgs.vim pkgs.busybox ];
systemd.users.root.shell = "/bin/bash";
network.ssh = {
enable = true;
port = 22;
@ -102,7 +126,13 @@ in
options = [ "defaults" "size=2G" "mode=755" ]; };
"/persist" =
{ 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; };
};