From 5a0a36726756bc2a88770f8fd65418b6d3ce007b Mon Sep 17 00:00:00 2001 From: Caroline Larimore Date: Mon, 3 Feb 2025 19:30:44 -0800 Subject: migration: barebones c-pc config --- flake.lock | 93 ++++++++++++++++++++++++- flake.nix | 75 +++++++++++--------- hosts/c-pc/hardware.nix | 59 ---------------- hosts/c-pc/network.nix | 28 -------- snowfall/modules/nixos/system/default.nix | 21 ++++++ snowfall/systems/x86_64-linux/c-pc/default.nix | 17 +++++ snowfall/systems/x86_64-linux/c-pc/hardware.nix | 59 ++++++++++++++++ snowfall/systems/x86_64-linux/c-pc/network.nix | 25 +++++++ 8 files changed, 258 insertions(+), 119 deletions(-) delete mode 100644 hosts/c-pc/hardware.nix delete mode 100644 hosts/c-pc/network.nix create mode 100644 snowfall/modules/nixos/system/default.nix create mode 100644 snowfall/systems/x86_64-linux/c-pc/default.nix create mode 100644 snowfall/systems/x86_64-linux/c-pc/hardware.nix create mode 100644 snowfall/systems/x86_64-linux/c-pc/network.nix diff --git a/flake.lock b/flake.lock index 577efed..94aa16a 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -34,6 +50,43 @@ "type": "github" } }, + "flake-utils-plus": { + "inputs": { + "flake-utils": "flake-utils_2" + }, + "locked": { + "lastModified": 1715533576, + "narHash": "sha256-fT4ppWeCJ0uR300EH3i7kmgRZnAVxrH+XtK09jQWihk=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "3542fe9126dc492e53ddd252bb0260fe035f2c0f", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "3542fe9126dc492e53ddd252bb0260fe035f2c0f", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -126,7 +179,30 @@ "home-manager": "home-manager", "impermanence": "impermanence", "nix-minecraft": "nix-minecraft", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "snowfall-lib": "snowfall-lib" + } + }, + "snowfall-lib": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils-plus": "flake-utils-plus", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1736130495, + "narHash": "sha256-4i9nAJEZFv7vZMmrE0YG55I3Ggrtfo5/T07JEpEZ/RM=", + "owner": "snowfallorg", + "repo": "lib", + "rev": "02d941739f98a09e81f3d2d9b3ab08918958beac", + "type": "github" + }, + "original": { + "owner": "snowfallorg", + "repo": "lib", + "type": "github" } }, "systems": { @@ -143,6 +219,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4250df2..81dc6dc 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { description = "Nixos config flake"; - + inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; @@ -18,38 +18,51 @@ nix-minecraft.url = "github:CartConnoisseur/nix-minecraft"; }; - outputs = {nixpkgs, ...} @inputs: { - nixosConfigurations = { - c-pc = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; - modules = [ - ./hosts/c-pc/configuration.nix - inputs.home-manager.nixosModules.default - inputs.impermanence.nixosModules.impermanence - inputs.nix-minecraft.nixosModules.minecraft-servers - (import ./overlays) - ]; - }; + outputs = inputs: + inputs.snowfall-lib.mkFlake { + inherit inputs; + src = ./.; - copenhagen = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; - modules = [ - ./hosts/copenhagen/configuration.nix - inputs.home-manager.nixosModules.default - inputs.impermanence.nixosModules.impermanence - inputs.nix-minecraft.nixosModules.minecraft-servers - ]; - }; + snowfall = { + root = ./snowfall; + namespace = "cxl"; - phoenix = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; - modules = [ - ./hosts/phoenix/configuration.nix - inputs.home-manager.nixosModules.default - inputs.impermanence.nixosModules.impermanence - inputs.nix-minecraft.nixosModules.minecraft-servers - ]; + meta = { + name = "cxl"; + title = "cxl flake"; + }; }; }; - }; + # nixosConfigurations = { + # c-pc = nixpkgs.lib.nixosSystem { + # specialArgs = { inherit inputs; }; + # modules = [ + # ./hosts/c-pc/configuration.nix + # inputs.home-manager.nixosModules.default + # inputs.impermanence.nixosModules.impermanence + # inputs.nix-minecraft.nixosModules.minecraft-servers + # (import ./overlays) + # ]; + # }; + + # copenhagen = nixpkgs.lib.nixosSystem { + # specialArgs = { inherit inputs; }; + # modules = [ + # ./hosts/copenhagen/configuration.nix + # inputs.home-manager.nixosModules.default + # inputs.impermanence.nixosModules.impermanence + # inputs.nix-minecraft.nixosModules.minecraft-servers + # ]; + # }; + + # phoenix = nixpkgs.lib.nixosSystem { + # specialArgs = { inherit inputs; }; + # modules = [ + # ./hosts/phoenix/configuration.nix + # inputs.home-manager.nixosModules.default + # inputs.impermanence.nixosModules.impermanence + # inputs.nix-minecraft.nixosModules.minecraft-servers + # ]; + # }; + } diff --git a/hosts/c-pc/hardware.nix b/hosts/c-pc/hardware.nix deleted file mode 100644 index 68cf8bd..0000000 --- a/hosts/c-pc/hardware.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ config, lib, pkgs, modulesPath, ... }: - -{ - imports = [ - (modulesPath + "/installer/scan/not-detected.nix") - ]; - - boot = { - loader.grub = { - enable = true; - - useOSProber = true; - - zfsSupport = true; - efiSupport = true; - efiInstallAsRemovable = true; - - mirroredBoots = [ - { devices = [ "nodev" ]; path = "/boot"; } - ]; - }; - - initrd = { - availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; - kernelModules = [ "amdgpu" ]; - - postDeviceCommands = lib.mkAfter '' - zfs rollback -r zpool/root@blank && zfs rollback -r zpool/home@blank - ''; - - postMountCommands = lib.mkAfter '' - chmod u=rw,g=,o= /secrets - ''; - }; - - kernelModules = [ "kvm-amd" ]; - extraModulePackages = [ ]; - - supportedFilesystems = [ "ntfs" ]; - }; - - fileSystems = { - "/" = { fsType = "zfs"; neededForBoot = true; device = "zpool/root"; }; - "/nix" = { fsType = "zfs"; neededForBoot = true; device = "zpool/nix"; }; - "/home" = { fsType = "zfs"; neededForBoot = true; device = "zpool/home"; }; - "/persist" = { fsType = "zfs"; neededForBoot = true; device = "zpool/persist"; }; - "/persist/secure" = { fsType = "zfs"; neededForBoot = true; device = "zpool/secure/persist"; }; - "/secrets" = { fsType = "zfs"; neededForBoot = true; device = "zpool/secure/secrets"; }; - - "/boot" = { fsType = "vfat"; device = "/dev/disk/by-uuid/12CE-A600"; }; - - "/mnt/4tb" = { fsType = "ext4"; device = "/dev/disk/by-label/4tb"; }; - }; - - swapDevices = [ ]; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/hosts/c-pc/network.nix b/hosts/c-pc/network.nix deleted file mode 100644 index 969b49f..0000000 --- a/hosts/c-pc/network.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ ... }: - -{ - networking = { - hostName = "c-pc"; - hostId = "23ce94ff"; - - useDHCP = true; - - wireless = { - enable = true; - - # Import /etc/wpa_supplicant.conf networks - allowAuxiliaryImperativeNetworks = true; - }; - - firewall = { - enable = false; - - allowedTCPPorts = [ 8096 50000 ]; - allowedUDPPorts = [ ]; - }; - }; - - environment.etc."wpa_supplicant.conf" = { - source = "/secrets/wireless.conf"; - }; -} diff --git a/snowfall/modules/nixos/system/default.nix b/snowfall/modules/nixos/system/default.nix new file mode 100644 index 0000000..a6a570b --- /dev/null +++ b/snowfall/modules/nixos/system/default.nix @@ -0,0 +1,21 @@ +{ options, config, lib, namespace, ... }: + +with lib; with lib.${namespace}; let + cfg = config.${namespace}.system; +in { + options.${namespace}.system = with types; { + hostname = mkOption { + type = strMatching "^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$"; + }; + + id = mkOption { + default = null; + type = nullOr str; + }; + }; + + config = { + networking.hostName = cfg.hostname; + networking.hostId = cfg.id; + }; +} \ No newline at end of file diff --git a/snowfall/systems/x86_64-linux/c-pc/default.nix b/snowfall/systems/x86_64-linux/c-pc/default.nix new file mode 100644 index 0000000..ad4b923 --- /dev/null +++ b/snowfall/systems/x86_64-linux/c-pc/default.nix @@ -0,0 +1,17 @@ +{ lib, namespace, ... }: + +with lib; with lib.${namespace}; { + imports = [ + ./hardware.nix + ./network.nix + ]; + + cxl = { + system = { + hostname = "c-pc"; + id = "23ce94ff"; + }; + }; + + system.stateVersion = "23.11"; +} \ No newline at end of file diff --git a/snowfall/systems/x86_64-linux/c-pc/hardware.nix b/snowfall/systems/x86_64-linux/c-pc/hardware.nix new file mode 100644 index 0000000..68cf8bd --- /dev/null +++ b/snowfall/systems/x86_64-linux/c-pc/hardware.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot = { + loader.grub = { + enable = true; + + useOSProber = true; + + zfsSupport = true; + efiSupport = true; + efiInstallAsRemovable = true; + + mirroredBoots = [ + { devices = [ "nodev" ]; path = "/boot"; } + ]; + }; + + initrd = { + availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + kernelModules = [ "amdgpu" ]; + + postDeviceCommands = lib.mkAfter '' + zfs rollback -r zpool/root@blank && zfs rollback -r zpool/home@blank + ''; + + postMountCommands = lib.mkAfter '' + chmod u=rw,g=,o= /secrets + ''; + }; + + kernelModules = [ "kvm-amd" ]; + extraModulePackages = [ ]; + + supportedFilesystems = [ "ntfs" ]; + }; + + fileSystems = { + "/" = { fsType = "zfs"; neededForBoot = true; device = "zpool/root"; }; + "/nix" = { fsType = "zfs"; neededForBoot = true; device = "zpool/nix"; }; + "/home" = { fsType = "zfs"; neededForBoot = true; device = "zpool/home"; }; + "/persist" = { fsType = "zfs"; neededForBoot = true; device = "zpool/persist"; }; + "/persist/secure" = { fsType = "zfs"; neededForBoot = true; device = "zpool/secure/persist"; }; + "/secrets" = { fsType = "zfs"; neededForBoot = true; device = "zpool/secure/secrets"; }; + + "/boot" = { fsType = "vfat"; device = "/dev/disk/by-uuid/12CE-A600"; }; + + "/mnt/4tb" = { fsType = "ext4"; device = "/dev/disk/by-label/4tb"; }; + }; + + swapDevices = [ ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/snowfall/systems/x86_64-linux/c-pc/network.nix b/snowfall/systems/x86_64-linux/c-pc/network.nix new file mode 100644 index 0000000..aa7e075 --- /dev/null +++ b/snowfall/systems/x86_64-linux/c-pc/network.nix @@ -0,0 +1,25 @@ +{ ... }: + +{ + networking = { + useDHCP = true; + + wireless = { + enable = true; + + # Import /etc/wpa_supplicant.conf networks + allowAuxiliaryImperativeNetworks = true; + }; + + firewall = { + enable = false; + + allowedTCPPorts = [ 8096 50000 ]; + allowedUDPPorts = [ ]; + }; + }; + + environment.etc."wpa_supplicant.conf" = { + source = "/secrets/wireless.conf"; + }; +} -- cgit v1.2.3