pxeboot with nixos host configured and tested
This commit is contained in:
parent
1dd7fac8ed
commit
2d4cf0b147
9 changed files with 268 additions and 89 deletions
25
common.nix
25
common.nix
|
|
@ -1,10 +1,16 @@
|
|||
{ config, pkgs, ... }: {
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
boot = {
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
loader.limine = {
|
||||
enable = true;
|
||||
panicOnChecksumMismatch = true;
|
||||
secureBoot.enable = true;
|
||||
};
|
||||
zswap = {
|
||||
enable = true;
|
||||
|
|
@ -25,25 +31,14 @@
|
|||
speedtest-go
|
||||
];
|
||||
i18n.defaultLocale = "ru_RU.UTF-8";
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
networking.networkmanager.enable = true;
|
||||
nix.settings.experimental-features = [
|
||||
"flakes"
|
||||
"nix-command"
|
||||
];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
services.swapspace.enable = true;
|
||||
sops = {
|
||||
age.keyFile = "/var/lib/sops-nix/key.txt";
|
||||
defaultSopsFile = ./.secrets.yaml;
|
||||
secrets.root-passwd = { };
|
||||
};
|
||||
system.stateVersion = "26.11";
|
||||
systemd.tmpfiles.rules = [
|
||||
"L /root/backup/base/nixos - - - - /etc/nixos"
|
||||
"L /root/backup/base/sbctl - - - - /var/lib/sbctl"
|
||||
"L /root/backup/base/sops-nix - - - - /var/lib/sops-nix"
|
||||
"d /root/backup"
|
||||
"d /root/backup/base"
|
||||
];
|
||||
time.timeZone = "Asia/Chita";
|
||||
users.users.root.hashedPasswordFile = config.sops.secrets.root-passwd.path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
{ config, lib, ... }: {
|
||||
boot = {
|
||||
initrd = {
|
||||
availableKernelModules = [
|
||||
|
|
@ -34,8 +28,6 @@
|
|||
};
|
||||
};
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
swapDevices = [
|
||||
{
|
||||
device = "/var/lib/swapfile";
|
||||
|
|
|
|||
|
|
@ -38,12 +38,7 @@
|
|||
sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
nixos-pxeboot = nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
./pxeboot/configuration.nix
|
||||
sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
nixos-pxeboot = nixpkgs.lib.nixosSystem { modules = [ ./pxeboot/configuration.nix ]; };
|
||||
nixos-server = nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
./server/configuration.nix
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
boot = {
|
||||
extraModulePackages = [ config.boot.kernelPackages.amneziawg ];
|
||||
kernelModules = [ "amneziawg" ];
|
||||
loader.limine.secureBoot.enable = true;
|
||||
};
|
||||
fileSystems = {
|
||||
"/".options = [ "noatime" ];
|
||||
|
|
@ -55,8 +56,20 @@
|
|||
];
|
||||
};
|
||||
};
|
||||
sops.secrets = {
|
||||
sops = {
|
||||
age.keyFile = "/var/lib/sops-nix/key.txt";
|
||||
defaultSopsFile = ../.secrets.yaml;
|
||||
secrets = {
|
||||
awg-obf = { };
|
||||
root-passwd = { };
|
||||
wifi-env = { };
|
||||
};
|
||||
};
|
||||
systemd.tmpfiles.rules = [
|
||||
"L /root/backup/base/nixos - - - - /etc/nixos"
|
||||
"L /root/backup/base/sbctl - - - - /var/lib/sbctl"
|
||||
"L /root/backup/base/sops-nix - - - - /var/lib/sops-nix"
|
||||
"d /root/backup/base"
|
||||
];
|
||||
users.users.root.hashedPasswordFile = config.sops.secrets.root-passwd.path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,21 @@
|
|||
internalInterfaces = [ "br0" ];
|
||||
};
|
||||
networkmanager.ensureProfiles.profiles = {
|
||||
dhcp-bridge = {
|
||||
bridge.stp = false;
|
||||
connection = {
|
||||
id = "dhcp-bridge";
|
||||
interface-name = "br0";
|
||||
type = "bridge";
|
||||
};
|
||||
};
|
||||
slave-ethernet.connection = {
|
||||
controller = "br0";
|
||||
id = "slave-ethernet";
|
||||
type = "ethernet";
|
||||
};
|
||||
static-bridge = {
|
||||
bridge.stp = false;
|
||||
connection = {
|
||||
id = "static-bridge";
|
||||
interface-name = "br0";
|
||||
|
|
@ -39,17 +48,12 @@
|
|||
method = "manual";
|
||||
};
|
||||
};
|
||||
dhcp-bridge.connection = {
|
||||
id = "dhcp-bridge";
|
||||
interface-name = "br0";
|
||||
type = "bridge";
|
||||
};
|
||||
};
|
||||
};
|
||||
services = {
|
||||
dnsmasq.settings = {
|
||||
bind-interfaces = true;
|
||||
dhcp-boot = "grubx64.efi";
|
||||
dhcp-boot = "efi/boot/BOOTX64.EFI";
|
||||
dhcp-range = [
|
||||
"10.2.0.2,10.2.255.254,12h"
|
||||
"fc02::2,fc02::ffff:ffff:ffff:ffff,12h"
|
||||
|
|
@ -57,12 +61,12 @@
|
|||
enable-ra = true;
|
||||
enable-tftp = true;
|
||||
interface = "br0";
|
||||
tftp-root = "/srv/tftp";
|
||||
tftp-root = "/srv/pxe/nixos/boot";
|
||||
};
|
||||
nfs.server = {
|
||||
enable = true;
|
||||
exports."/srv/nfs/root"."10.2.0.0/16" = [
|
||||
"mp"
|
||||
exports."/srv/pxe/export"."10.2.0.0/16" = [
|
||||
"fsid=0"
|
||||
"no_root_squash"
|
||||
"rw"
|
||||
];
|
||||
|
|
@ -70,31 +74,22 @@
|
|||
};
|
||||
systemd = {
|
||||
services.pxeboot = {
|
||||
before = [ "nfs-server.service" ];
|
||||
path = with pkgs; [
|
||||
curl
|
||||
grub2_efi
|
||||
xz
|
||||
nix
|
||||
nixos-install
|
||||
util-linux
|
||||
];
|
||||
#requiredBy = [ "nfs-server.service" ];
|
||||
script = ''
|
||||
if [ ! -e /srv/nfs/nixos ]; then
|
||||
mkdir -p /srv/nfs/nixos
|
||||
until curl --head --max-time 3 https://bogaledev.ru; do sleep 5; done
|
||||
# nixos-install ...
|
||||
# extract initramfs, linux
|
||||
fi
|
||||
cd /srv/tftp
|
||||
if [ ! -e grubx64.efi ]; then
|
||||
grub-mkstandalone -O x86_64-efi --compress=xz -o grubx64.efi \
|
||||
--modules=efinet /boot/grub/grub.cfg=<(cat <<' EOF'
|
||||
linux $cmdpath/linux rw ip=dhcp root=nfs4:$net_default_server:/srv/nfs/root
|
||||
initrd $cmdpath/initramfs
|
||||
boot
|
||||
EOF)
|
||||
fi
|
||||
(printf '{\n boot.initrd.availableKernelModules = [\n'
|
||||
cd ${config.boot.kernelPackages.kernel.modules}/lib/modules/*/kernel/drivers/net/ethernet
|
||||
find -type f | sed 's/^.*\/\([^.]*\).*$/ "\1"/' | sort
|
||||
printf ' ];\n}') > /etc/nixos/pxeboot/ethernet.nix
|
||||
cd /srv/pxe
|
||||
nixos-install --flake "/etc/nixos#nixos-pxeboot" \
|
||||
--no-channel-copy --no-root-passwd --root $PWD/nixos
|
||||
mountpoint -q export || mount -B --mkdir nixos export
|
||||
'';
|
||||
};
|
||||
tmpfiles.rules = [ "d /srv/tftp" ];
|
||||
tmpfiles.rules = [ "d /srv/pxe/nixos/boot" ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,21 @@
|
|||
{ config, pkgs, ... }: {
|
||||
{ pkgs, ... }: {
|
||||
boot = {
|
||||
initrd = {
|
||||
availableKernelModules = [ "nfsv4" ];
|
||||
network.enable = true;
|
||||
systemd.initrdBin = [ pkgs.nfs-utils ];
|
||||
};
|
||||
kernelParams = [ "ip=dhcp" ];
|
||||
};
|
||||
fileSystems."/" = {
|
||||
device = "10.2.0.1:/";
|
||||
fsType = "nfs4";
|
||||
};
|
||||
hardware.enableAllHardware = true;
|
||||
imports = [
|
||||
../common.nix
|
||||
./hardware.nix
|
||||
./ethernet.nix
|
||||
];
|
||||
networking.hostName = "nixos-pxeboot";
|
||||
services.getty.autologinUser = "root";
|
||||
}
|
||||
|
|
|
|||
198
pxeboot/ethernet.nix
Normal file
198
pxeboot/ethernet.nix
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
{
|
||||
boot.initrd.availableKernelModules = [
|
||||
"3c59x"
|
||||
"8139cp"
|
||||
"8139too"
|
||||
"8390"
|
||||
"adin1110"
|
||||
"adin1140"
|
||||
"altera_tse"
|
||||
"alx"
|
||||
"amd8111e"
|
||||
"amd-xgbe"
|
||||
"atl1"
|
||||
"atl1c"
|
||||
"atl1e"
|
||||
"atl2"
|
||||
"atlantic"
|
||||
"ax88796c"
|
||||
"b44"
|
||||
"bcmsysport"
|
||||
"be2net"
|
||||
"bna"
|
||||
"bng_en"
|
||||
"bnx2"
|
||||
"bnx2x"
|
||||
"bnxt_en"
|
||||
"cassini"
|
||||
"cavium_ptp"
|
||||
"ch_ipsec"
|
||||
"ch_ktls"
|
||||
"cnic"
|
||||
"cxgb"
|
||||
"cxgb3"
|
||||
"cxgb4"
|
||||
"cxgb4vf"
|
||||
"de2104x"
|
||||
"dinghai10e"
|
||||
"dl2k"
|
||||
"dmfe"
|
||||
"dwc-xlgmac"
|
||||
"dwmac-dwc-qos-eth"
|
||||
"dwmac-generic"
|
||||
"dwmac-intel"
|
||||
"dwmac-intel-plat"
|
||||
"dwmac-motorcomm"
|
||||
"e100"
|
||||
"e1000"
|
||||
"e1000e"
|
||||
"ec_bhf"
|
||||
"eea"
|
||||
"ena"
|
||||
"enc28j60"
|
||||
"encx24j600"
|
||||
"encx24j600-regmap"
|
||||
"enic"
|
||||
"epic100"
|
||||
"et131x"
|
||||
"ethoc"
|
||||
"fbnic"
|
||||
"fealnx"
|
||||
"fm10k"
|
||||
"forcedeth"
|
||||
"funcore"
|
||||
"funeth"
|
||||
"gemini"
|
||||
"genet"
|
||||
"gve"
|
||||
"hibmcge"
|
||||
"hinic"
|
||||
"hinic3"
|
||||
"i40e"
|
||||
"iavf"
|
||||
"ice"
|
||||
"idpf"
|
||||
"igb"
|
||||
"igbvf"
|
||||
"igc"
|
||||
"ionic"
|
||||
"ixd"
|
||||
"ixgbe"
|
||||
"ixgbevf"
|
||||
"jme"
|
||||
"ks8842"
|
||||
"ks8851_common"
|
||||
"ks8851_par"
|
||||
"ks8851_spi"
|
||||
"ksz884x"
|
||||
"lan743x"
|
||||
"lan865x"
|
||||
"lan966x-switch"
|
||||
"libcxgb"
|
||||
"libeth"
|
||||
"libeth_xdp"
|
||||
"libie"
|
||||
"libie_adminq"
|
||||
"libie_cp"
|
||||
"libie_fwlog"
|
||||
"libie_pci"
|
||||
"libwx"
|
||||
"liquidio"
|
||||
"liquidio-core"
|
||||
"liquidio_vf"
|
||||
"litex_liteeth"
|
||||
"ll_temac"
|
||||
"macb"
|
||||
"macb_pci"
|
||||
"mana"
|
||||
"mlx4_core"
|
||||
"mlx4_en"
|
||||
"mlx5_core"
|
||||
"mlx5_dpll"
|
||||
"mlxfw"
|
||||
"mlxsw_core"
|
||||
"mlxsw_i2c"
|
||||
"mlxsw_minimal"
|
||||
"mlxsw_pci"
|
||||
"mlxsw_spectrum"
|
||||
"mscc_ocelot"
|
||||
"mscc_ocelot_switch_lib"
|
||||
"mse102x"
|
||||
"mvmdio"
|
||||
"myri10ge"
|
||||
"natsemi"
|
||||
"ne2k-pci"
|
||||
"netxen_nic"
|
||||
"nfp"
|
||||
"ngbe"
|
||||
"ngbevf"
|
||||
"nicpf"
|
||||
"nicvf"
|
||||
"niu"
|
||||
"nixge"
|
||||
"nps_enet"
|
||||
"ns83820"
|
||||
"oa_tc6"
|
||||
"octeon_ep"
|
||||
"octeon_ep_vf"
|
||||
"pcnet32"
|
||||
"pcnet_cs"
|
||||
"pds_core"
|
||||
"prestera"
|
||||
"prestera_pci"
|
||||
"qca_7k_common"
|
||||
"qcaspi"
|
||||
"qcauart"
|
||||
"qcom-emac"
|
||||
"qed"
|
||||
"qede"
|
||||
"qla3xxx"
|
||||
"qlcnic"
|
||||
"r6040"
|
||||
"r8169"
|
||||
"rmnet"
|
||||
"rnpgbe"
|
||||
"rocker"
|
||||
"rtase"
|
||||
"samsung-sxgbe"
|
||||
"sc92031"
|
||||
"sfc"
|
||||
"sfc-falcon"
|
||||
"sfc-siena"
|
||||
"sis190"
|
||||
"sis900"
|
||||
"skge"
|
||||
"sky2"
|
||||
"slicoss"
|
||||
"smsc911x"
|
||||
"smsc9420"
|
||||
"starfire"
|
||||
"stmmac"
|
||||
"stmmac_libpci"
|
||||
"stmmac-pci"
|
||||
"stmmac-platform"
|
||||
"sundance"
|
||||
"sungem"
|
||||
"sunhme"
|
||||
"tehuti"
|
||||
"tg3"
|
||||
"thunder_bgx"
|
||||
"thunder_xcv"
|
||||
"tlan"
|
||||
"tn40xx"
|
||||
"tsnep"
|
||||
"tulip"
|
||||
"txgbe"
|
||||
"txgbevf"
|
||||
"typhoon"
|
||||
"uli526x"
|
||||
"via-rhine"
|
||||
"via-velocity"
|
||||
"w5100"
|
||||
"w5100-spi"
|
||||
"winbond-840"
|
||||
"xilinx_emac"
|
||||
"xilinx_emaclite"
|
||||
"xirc2ps_cs"
|
||||
];
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
boot.initrd.network.enable = true;
|
||||
fileSystems."/" = {
|
||||
device = "";
|
||||
fsType = "nfs";
|
||||
};
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
||||
|
|
@ -1,10 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
{ config, lib, ... }: {
|
||||
boot = {
|
||||
initrd = {
|
||||
availableKernelModules = [
|
||||
|
|
@ -36,6 +30,4 @@
|
|||
};
|
||||
};
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue