From 13ca1dc20569c188f9e879ef547a69323171272a Mon Sep 17 00:00:00 2001 From: JuliusFreudenberger Date: Fri, 27 Mar 2026 01:36:29 +0100 Subject: [PATCH] Add config for busch Busch is the proxmox host used for various vms, which will be defined through terraform or similar. --- flake.nix | 5 +- .../{nixos-server-test => busch}/default.nix | 27 +++-- hosts/busch/disko.nix | 107 ++++++++++++++++++ hosts/busch/hardware-configuration.nix | 22 ++++ .../hardware-configuration.nix | 31 ----- 5 files changed, 151 insertions(+), 41 deletions(-) rename hosts/{nixos-server-test => busch}/default.nix (83%) create mode 100644 hosts/busch/disko.nix create mode 100644 hosts/busch/hardware-configuration.nix delete mode 100644 hosts/nixos-server-test/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index 6615b6c..04be147 100644 --- a/flake.nix +++ b/flake.nix @@ -115,7 +115,7 @@ ]; }; - server = nixpkgs.lib.nixosSystem rec { + busch = nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; specialArgs = { @@ -123,7 +123,8 @@ }; modules = [ - ./hosts/nixos-server-test + ./hosts/busch + disko.nixosModules.disko proxmox-nixos.nixosModules.proxmox-ve ({...}: { diff --git a/hosts/nixos-server-test/default.nix b/hosts/busch/default.nix similarity index 83% rename from hosts/nixos-server-test/default.nix rename to hosts/busch/default.nix index 409e2fa..bf64cb7 100644 --- a/hosts/nixos-server-test/default.nix +++ b/hosts/busch/default.nix @@ -3,10 +3,16 @@ { imports = [ + ./disko.nix + ../../modules/nix.nix + ../../modules/auto-upgrade.nix ../../modules/locale.nix ../../modules/server-cli.nix ../../modules/sshd.nix + ${inputs.secrets}/modules/opkssh.nix + + ../../modules/intel-cpu.nix # Include the results of the hardware scan. ./hardware-configuration.nix ]; @@ -14,11 +20,10 @@ boot = { loader.grub = { enable = true; - device = "/dev/vda"; }; tmp.useTmpfs = true; }; - networking.hostName = "nixos-server"; # Define your hostname. + networking.hostName = "busch"; # Define your hostname. users = { users = { julius = { @@ -43,12 +48,18 @@ ]; }; - services.proxmox-ve = { - enable = true; - ipAddress = "192.168.122.71"; + services = { + proxmox-ve = { + enable = true; + ipAddress = "192.168.7.252"; - # Make vmbr0 bridge visible in Proxmox web interface - bridges = [ "vmbr0" ]; + # Make vmbr0 bridge visible in Proxmox web interface + bridges = [ "vmbr0" ]; + }; + openiscsi = { + enable = true; + name = "busch"; + }; }; networking.useDHCP = false; @@ -57,7 +68,7 @@ enable = true; networks."10-lan" = { - matchConfig.Name = [ "enp1s0" ]; + matchConfig.Name = [ "enp0s25" ]; networkConfig = { Bridge = "vmbr0"; }; diff --git a/hosts/busch/disko.nix b/hosts/busch/disko.nix new file mode 100644 index 0000000..5563eae --- /dev/null +++ b/hosts/busch/disko.nix @@ -0,0 +1,107 @@ +{ + disko.devices = { + disk = { + disk1 = { + type = "disk"; + device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_256GB_S251NX0H423575T"; + content = { + type = "gpt"; + partitions = { + MBR = { + type = "EF02"; # for grub MBR + size = "1M"; + priority = 1; # Needs to be first partition + }; + ESP = { + priority = 1; + name = "ESP"; + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + crypt_p1 = { + size = "100%"; + content = { + type = "luks"; + name = "p1"; + settings = { + allowDiscards = true; + }; + }; + }; + }; + }; + }; + disk2 = { + type = "disk"; + device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_256GB_S251NXAG833792N"; + content = { + type = "gpt"; + partitions = { + MBR = { + type = "EF02"; # for grub MBR + size = "1M"; + priority = 1; # Needs to be first partition + }; + ESP = { + priority = 1; + name = "ESP"; + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot-fallback"; + mountOptions = [ "umask=0077" ]; + }; + }; + crypt_p2 = { + size = "100%"; + content = { + type = "luks"; + name = "p2"; + settings = { + allowDiscards = true; + }; + content = { + type = "btrfs"; + extraArgs = [ + "-d raid1" + "-m raid1" + "/dev/mapper/p1" + ]; + subvolumes = { + "/rootfs" = { + mountpoint = "/"; + }; + "/home" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/home"; + }; + "/nix" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/nix"; + }; + "/pve-cluster" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/var/lib/pve-cluster"; + }; + "/swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "32G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/busch/hardware-configuration.nix b/hosts/busch/hardware-configuration.nix new file mode 100644 index 0000000..2de4340 --- /dev/null +++ b/hosts/busch/hardware-configuration.nix @@ -0,0 +1,22 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "ehci_pci" "mpt3sas" "usbhid" "usb_storage" "sr_mod" ]; + boot.initrd.kernelModules = [ "vfio_pci" "vfio" "vfio_iommu_type1" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + boot.kernelParams = [ "intel_iommu=on" "iommu=pt" "vfio-pci.ids=1000:0087" ]; + + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/nixos-server-test/hardware-configuration.nix b/hosts/nixos-server-test/hardware-configuration.nix deleted file mode 100644 index 6dfd7c4..0000000 --- a/hosts/nixos-server-test/hardware-configuration.nix +++ /dev/null @@ -1,31 +0,0 @@ -# Do not modify this file! It was generated by ‘nixos-generate-config’ -# and may be overwritten by future invocations. Please make changes -# to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - -{ - imports = - [ (modulesPath + "/profiles/qemu-guest.nix") - ]; - - boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = - { device = "/dev/disk/by-uuid/e46c412a-8b6d-41b8-b53c-65d7a8fc39ed"; - fsType = "ext4"; - }; - - swapDevices = [ ]; - - # Enables DHCP on each ethernet and wireless interface. In case of scripted networking - # (the default) this is the recommended approach. When using systemd-networkd it's - # still possible to use this option, but it's recommended to use it in conjunction - # with explicit per-interface declarations with `networking.interfaces..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; -}