From 22c218e37aaf1ab1a425615dd91028dbea0eb24b Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Wed, 2 Apr 2025 04:49:11 +0800 Subject: [PATCH] refactor: cleaned up flake --- flake.nix | 50 ++++++++++++---------------- modules/filesystems/impermanence.nix | 4 +-- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/flake.nix b/flake.nix index e5458bc..cdfa162 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ ... }@inputs: let - mkSystem = type: hostname: { + mkSystem = type: hostname: bootDisk: { name = "${hostname}"; value = let @@ -15,11 +15,10 @@ inputs type hostname + bootDisk ; }; inherit (inputs.nixpkgs) lib; - mkDiskConfig = - device: (import ./modules/filesystems/impermanence.nix { inherit inputs lib device; }); commonModules = [ ./modules/boot.nix ./modules/bootloaders/systemd-boot.nix @@ -29,45 +28,40 @@ ./modules/shell.nix ./modules/users.nix ]; - graphicalModules = lib.optionals (type == "graphical") [ + graphicalModules = [ ./modules/graphical.nix ]; in inputs.nixpkgs.lib.nixosSystem { specialArgs = args; - modules = builtins.concatLists [ + modules = commonModules - graphicalModules - # Options for specific hostnames. - (lib.optionals (hostname == "nemesis") [ - # mkDiskConfig - # "nvme-nvme.c0a9-323332354536453737343334-435432303030503353534438-00000001" - ./modules/filesystems/hw-nemesis.nix - ./modules/hardware/cpu_amd.nix - ./modules/hardware/nvidia.nix - ]) - (lib.optionals (hostname == "mellinoe") [ - mkDiskConfig - "/dev/disk/by-id/nvme-eui.01000000000000008ce38e04019a68ab" + ++ lib.optionals (type == "graphical") graphicalModules + ++ + # Options for specific hostnames. + (lib.optionals (hostname == "nemesis") [ + ./modules/filesystems/hw-nemesis.nix + ./modules/hardware/cpu_amd.nix + ./modules/hardware/nvidia.nix + ]) + ++ (lib.optionals (hostname == "mellinoe") [ + ./modules/filesystems/impermanence.nix ./modules/hardware/cpu_intel.nix ]) - (lib.optionals (hostname == "apollo") [ - (import ./modules/filesystems/impermanence.nix { - inherit inputs lib; - device = "/dev/disk/by-id/nvme-eui.002538d221b47b01"; - - }) + ++ (lib.optionals (hostname == "apollo") [ + ./modules/filesystems/impermanence.nix ./modules/hardware/cpu_intel.nix - ]) - ]; + ]); }; }; in { nixosConfigurations = builtins.listToAttrs [ - (mkSystem "graphical" "nemesis") - (mkSystem "graphical" "mellinoe") - (mkSystem "headless" "apollo") + (mkSystem "graphical" "nemesis" + "nvme-nvme.c0a9-323332354536453737343334-435432303030503353534438-00000001" + ) + (mkSystem "graphical" "mellinoe" "/dev/disk/by-id/nvme-eui.01000000000000008ce38e04019a68ab") + (mkSystem "headless" "apollo" "/dev/disk/by-id/nvme-eui.002538d221b47b01") ]; }; inputs = { diff --git a/modules/filesystems/impermanence.nix b/modules/filesystems/impermanence.nix index ad80f10..60cb9c9 100644 --- a/modules/filesystems/impermanence.nix +++ b/modules/filesystems/impermanence.nix @@ -1,7 +1,7 @@ { inputs, lib, - device ? throw "Set this to your disk device", + bootDisk, ... }: { @@ -11,7 +11,7 @@ ]; # Disk Partitioning disko.devices.disk.main = { - inherit device; + device = bootDisk; type = "disk"; content.type = "gpt"; content.partitions = {