refactor: cleaned up flake

This commit is contained in:
Mohammad Rafiq 2025-04-02 04:49:11 +08:00
parent 6ff2570404
commit 22c218e37a
No known key found for this signature in database
2 changed files with 24 additions and 30 deletions

View file

@ -5,7 +5,7 @@
... ...
}@inputs: }@inputs:
let let
mkSystem = type: hostname: { mkSystem = type: hostname: bootDisk: {
name = "${hostname}"; name = "${hostname}";
value = value =
let let
@ -15,11 +15,10 @@
inputs inputs
type type
hostname hostname
bootDisk
; ;
}; };
inherit (inputs.nixpkgs) lib; inherit (inputs.nixpkgs) lib;
mkDiskConfig =
device: (import ./modules/filesystems/impermanence.nix { inherit inputs lib device; });
commonModules = [ commonModules = [
./modules/boot.nix ./modules/boot.nix
./modules/bootloaders/systemd-boot.nix ./modules/bootloaders/systemd-boot.nix
@ -29,45 +28,40 @@
./modules/shell.nix ./modules/shell.nix
./modules/users.nix ./modules/users.nix
]; ];
graphicalModules = lib.optionals (type == "graphical") [ graphicalModules = [
./modules/graphical.nix ./modules/graphical.nix
]; ];
in in
inputs.nixpkgs.lib.nixosSystem { inputs.nixpkgs.lib.nixosSystem {
specialArgs = args; specialArgs = args;
modules = builtins.concatLists [ modules =
commonModules commonModules
graphicalModules ++ lib.optionals (type == "graphical") graphicalModules
# Options for specific hostnames. ++
(lib.optionals (hostname == "nemesis") [ # Options for specific hostnames.
# mkDiskConfig (lib.optionals (hostname == "nemesis") [
# "nvme-nvme.c0a9-323332354536453737343334-435432303030503353534438-00000001" ./modules/filesystems/hw-nemesis.nix
./modules/filesystems/hw-nemesis.nix ./modules/hardware/cpu_amd.nix
./modules/hardware/cpu_amd.nix ./modules/hardware/nvidia.nix
./modules/hardware/nvidia.nix ])
]) ++ (lib.optionals (hostname == "mellinoe") [
(lib.optionals (hostname == "mellinoe") [ ./modules/filesystems/impermanence.nix
mkDiskConfig
"/dev/disk/by-id/nvme-eui.01000000000000008ce38e04019a68ab"
./modules/hardware/cpu_intel.nix ./modules/hardware/cpu_intel.nix
]) ])
(lib.optionals (hostname == "apollo") [ ++ (lib.optionals (hostname == "apollo") [
(import ./modules/filesystems/impermanence.nix { ./modules/filesystems/impermanence.nix
inherit inputs lib;
device = "/dev/disk/by-id/nvme-eui.002538d221b47b01";
})
./modules/hardware/cpu_intel.nix ./modules/hardware/cpu_intel.nix
]) ]);
];
}; };
}; };
in in
{ {
nixosConfigurations = builtins.listToAttrs [ nixosConfigurations = builtins.listToAttrs [
(mkSystem "graphical" "nemesis") (mkSystem "graphical" "nemesis"
(mkSystem "graphical" "mellinoe") "nvme-nvme.c0a9-323332354536453737343334-435432303030503353534438-00000001"
(mkSystem "headless" "apollo") )
(mkSystem "graphical" "mellinoe" "/dev/disk/by-id/nvme-eui.01000000000000008ce38e04019a68ab")
(mkSystem "headless" "apollo" "/dev/disk/by-id/nvme-eui.002538d221b47b01")
]; ];
}; };
inputs = { inputs = {

View file

@ -1,7 +1,7 @@
{ {
inputs, inputs,
lib, lib,
device ? throw "Set this to your disk device", bootDisk,
... ...
}: }:
{ {
@ -11,7 +11,7 @@
]; ];
# Disk Partitioning # Disk Partitioning
disko.devices.disk.main = { disko.devices.disk.main = {
inherit device; device = bootDisk;
type = "disk"; type = "disk";
content.type = "gpt"; content.type = "gpt";
content.partitions = { content.partitions = {