fix(mugetsu): partial netboot install

This commit is contained in:
arcnmx 2024-11-21 16:25:20 -08:00
parent a4157c1eb3
commit f0adb4dccc
5 changed files with 152 additions and 20 deletions

39
nixos/hw/c4130.nix Normal file
View file

@ -0,0 +1,39 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge mkDefault;
in {
imports = [
./metal.nix
];
boot = {
loader = {
systemd-boot.enable = mkDefault true;
};
initrd = {
systemd.network = mkIf config.networking.useNetworkd {
networks."40-eno1" = {
inherit (config.boot.initrd.systemd.network.links.eno1) matchConfig;
inherit (config.systemd.network.networks."40-eno1") address gateway DHCP networkConfig linkConfig;
};
links.eno1 = {
matchConfig = {
inherit (config.systemd.network.links.eno1.matchConfig) Type MACAddress;
};
};
};
availableKernelModules = mkMerge [
["ahci" "xhci_pci" "ehci_pci" "usbhid" "usb_storage" "sd_mod" "sr_mod"]
(mkIf config.boot.initrd.network.enable ["igb"])
];
};
};
environment.systemPackages = [
pkgs.ipmitool
];
}

11
nixos/hw/metal.nix Normal file
View file

@ -0,0 +1,11 @@
{
pkgs,
config,
lib,
...
}: {
environment.systemPackages = [
pkgs.pciutils
pkgs.usbutils
];
}

92
nixos/netboot/kyuuto.nix Normal file
View file

@ -0,0 +1,92 @@
{
config,
systemConfig,
access,
pkgs,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.modules) mkIf mkDefault mkMerge;
cfg = config.gensokyo-zone.netboot;
nfsEnabled = config.boot.initrd.supportedFilesystems.nfs or config.boot.initrd.supportedFilesystems.nfs4 or false;
in {
options.gensokyo-zone.netboot = with lib.types; {
# TODO: default = true;
boot.enable = mkEnableOption "nfs /boot";
nfs = {
package = mkPackageOption pkgs "nfs-utils" {
example = "pkgs.mkinitcpio-nfs-utils";
};
security = mkOption {
type = str;
default = "sys";
};
flags = mkOption {
type = listOf str;
default = [
"nolock" # required in order to mount in initrd when statd daemon isn't running
];
};
};
};
config = {
boot = {
initrd = {
network = {
enable = mkDefault true;
ssh = {
# TODO: enable = true;
};
};
availableKernelModules = mkIf nfsEnabled [
"nfsv4" "nfsv3"
];
extraUtilsCommands = mkIf (nfsEnabled && !config.boot.initrd.systemd.enable) ''
copy_bin_and_libs ${cfg.nfs.package}/sbin/mount.nfs
'';
systemd = {
enable = mkDefault true;
emergencyAccess = mkDefault true;
initrdBin = mkMerge [
(mkIf nfsEnabled [cfg.nfs.package])
(mkIf config.boot.initrd.network.enable [
pkgs.iproute2
])
[ pkgs.util-linux pkgs.gnugrep ]
];
network = mkIf config.networking.useNetworkd {
enable = mkDefault true;
};
};
};
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = false;
};
};
fileSystems = let
nfsUrl = access.proxyUrlFor {
serviceName = "nfs";
scheme = "";
defaultPort = 2049;
# XXX: consider using dns hostname here instead? (does this require the dns_resolver kernel module?)
getAddressFor = "getAddress4For";
} + ":/srv/fs/kyuuto/systems/${systemConfig.name}";
nfsOpts = [
"sec=${cfg.nfs.security}"
] ++ cfg.nfs.flags;
in {
"/" = {
device = "${nfsUrl}/root";
fsType = "nfs";
options = nfsOpts;
};
"/boot" = mkIf cfg.boot.enable {
device = "${nfsUrl}/boot";
fsType = "nfs";
options = nfsOpts;
};
};
};
}

View file

@ -1,30 +1,19 @@
{ {
meta,
config, config,
pkgs,
... ...
}: { }: {
environment.systemPackages = [ imports = let
pkgs.ipmitool inherit (meta) nixos;
in [
nixos.hw.c4130
]; ];
boot = {
initrd = {
availableKernelModules = ["ahci" "xhci_pci" "ehci_pci" "usbhid" "usb_storage" "sd_mod" "sr_mod"];
kernelModules = [];
};
kernelModules = [];
extraModulePackages = [];
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
};
fileSystems = { fileSystems = {
"/" = { "/boot" = {
# TODO device = "/dev/disk/by-label/EFI";
device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888"; fsType = "vfat";
fsType = "xfs"; options = ["fmask=0077" "dmask=0077"];
}; };
}; };

View file

@ -8,6 +8,7 @@
./hardware-configuration.nix ./hardware-configuration.nix
#nixos.sops #nixos.sops
nixos.base nixos.base
nixos.netboot.kyuuto
]; ];
system.stateVersion = "24.11"; system.stateVersion = "24.11";