From f57dc498fa6a59c2e0b0a77d0ec161fbf723e82b Mon Sep 17 00:00:00 2001 From: Giovanni d'Amelio Date: Sun, 5 Jan 2025 15:23:18 -0800 Subject: [PATCH] Start of config for manganese --- homelab.toml | 8 +++ src/nixosConfigurations/manganese.nix | 15 ++++ .../machines/manganese/default.nix | 45 ++++++++++++ src/nixosModules/machines/manganese/disko.nix | 70 +++++++++++++++++++ .../machines/manganese/hardware.nix | 32 +++++++++ 5 files changed, 170 insertions(+) create mode 100644 src/nixosConfigurations/manganese.nix create mode 100644 src/nixosModules/machines/manganese/default.nix create mode 100644 src/nixosModules/machines/manganese/disko.nix create mode 100644 src/nixosModules/machines/manganese/hardware.nix diff --git a/homelab.toml b/homelab.toml index 94ddcf7..301565e 100644 --- a/homelab.toml +++ b/homelab.toml @@ -49,6 +49,14 @@ useDescription = "Main NAS in the closet" targetHost = "10.0.128.214" targetUser = "server" +[machines.manganese] +hardwareDescription = "" +useDescription = "Handling all our monitoring as reliably as possible" + +[machines.carbon.deployment] +targetHost = "10.0.246.179" +targetUser = "server" + [machines.zirconium] hardwareDescription = "VM Running in Hetzner Cloud" useDescription = "Critical services running on a DigitalOcean VM" diff --git a/src/nixosConfigurations/manganese.nix b/src/nixosConfigurations/manganese.nix new file mode 100644 index 0000000..1e889b2 --- /dev/null +++ b/src/nixosConfigurations/manganese.nix @@ -0,0 +1,15 @@ +{ + root, + inputs, + ... +}: +inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + + extraModules = [ + # Not sure why this has to be an extraModule instead of a regular module + inputs.colmena.nixosModules.deploymentOptions + ]; + + modules = [root.nixosModules.machines.manganese.default]; +} diff --git a/src/nixosModules/machines/manganese/default.nix b/src/nixosModules/machines/manganese/default.nix new file mode 100644 index 0000000..732b054 --- /dev/null +++ b/src/nixosModules/machines/manganese/default.nix @@ -0,0 +1,45 @@ +{ + root, + super, + homelab, + ... +}: _: { + imports = [ + # Disk layout + super.disko + + # Hardware + super.hardware + + # Basic packages I want on every system + root.nixosModules.basic-packages + root.nixosModules.basic-settings + + # Add server user + root.nixosModules.users.server + + # Autosnapshot ZFS and send to NAS + # root.nixosModules.core.zfs-backup + # (_: { + # gio.services.zfs_backup = { + # enable = true; + # syncToGallium = true; + # datasets = [ + # "tank/home" + # "tank/nix" + # "tank/root" + # ]; + # }; + # }) + + ({pkgs, ...}: { + networking.hostId = "cf399625"; + + # ZFS snapshot browsing + environment.systemPackages = [pkgs.httm]; + + # Load the deployment config from our homelab.toml + inherit (homelab.machines.manganese) deployment; + }) + ]; +} diff --git a/src/nixosModules/machines/manganese/disko.nix b/src/nixosModules/machines/manganese/disko.nix new file mode 100644 index 0000000..ff2ba5b --- /dev/null +++ b/src/nixosModules/machines/manganese/disko.nix @@ -0,0 +1,70 @@ +{inputs, ...}: { + imports = [ + inputs.disko.nixosModules.disko + ]; + + config = { + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/disk/by-id/ata-SanDisk_SDSSDA120G_173948453212"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }; + }; + }; + }; + }; + zpool = { + tank = { + type = "zpool"; + postCreateHook = "zfs snapshot tank@blank"; + rootFsOptions = { + compression = "zstd"; + mountpoint = "none"; + }; + + datasets = { + reserve = { + type = "zfs_fs"; + options = { + mountpoint = "none"; + reservation = "5G"; + }; + }; + root = { + type = "zfs_fs"; + mountpoint = "/"; + postCreateHook = "zfs snapshot tank/root@blank"; + }; + nix = { + type = "zfs_fs"; + mountpoint = "/nix"; + }; + home = { + type = "zfs_fs"; + mountpoint = "/home"; + }; + }; + }; + }; + }; + }; +} diff --git a/src/nixosModules/machines/manganese/hardware.nix b/src/nixosModules/machines/manganese/hardware.nix new file mode 100644 index 0000000..2e9eec6 --- /dev/null +++ b/src/nixosModules/machines/manganese/hardware.nix @@ -0,0 +1,32 @@ +_: { + config, + lib, + ... +}: { + boot.initrd.availableKernelModules = ["ahci" "xhci_pci" "usb_storage" "usbhid" "sd_mod" "sdhci_pci"]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-intel"]; + boot.extraModulePackages = []; + + networking.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + time.timeZone = "America/Los_Angeles"; + + networking.hostName = "manganese"; + + boot.loader = { + systemd-boot = { + enable = true; + consoleMode = "auto"; + netbootxyz.enable = true; + }; + + efi.canTouchEfiVariables = true; + }; + boot.zfs.forceImportRoot = false; + boot.supportedFilesystems = ["zfs"]; + boot.initrd.supportedFilesystems = ["zfs"]; +}