mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
fix(mugetsu): partial netboot install
This commit is contained in:
parent
a4157c1eb3
commit
f0adb4dccc
5 changed files with 152 additions and 20 deletions
39
nixos/hw/c4130.nix
Normal file
39
nixos/hw/c4130.nix
Normal 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
11
nixos/hw/metal.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
environment.systemPackages = [
|
||||
pkgs.pciutils
|
||||
pkgs.usbutils
|
||||
];
|
||||
}
|
||||
92
nixos/netboot/kyuuto.nix
Normal file
92
nixos/netboot/kyuuto.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue