refactor hosts

This commit is contained in:
2025-12-03 18:57:48 -05:00
parent afa4e3b020
commit 0c913ec3be
3 changed files with 31 additions and 31 deletions

View File

@@ -17,11 +17,6 @@
lazyvim-nixvim.url = "github:azuwis/lazyvim-nixvim";
};
outputs = inputs@{ self, nixpkgs, home-manager, disko, nixos-generators, lazyvim-nixvim, ... }: {
nixosConfigurations = {
"nix-laptop1" = import ./hosts {
inherit inputs;
hostName = "nix-laptop1";
};
};
nixosConfigurations = import ./hosts { inherit inputs; };
};
}

View File

@@ -1,11 +1,10 @@
{ inputs, hostName, system ? "x86_64-linux" }:
{ inputs }:
let
nixpkgs = inputs.nixpkgs;
home-manager = inputs.home-manager;
disko = inputs.disko;
lib = nixpkgs.lib;
lib = nixpkgs.lib;
commonModules = [
../boot.nix
@@ -20,9 +19,7 @@ let
disko.devices = {
disk.main = {
type = "disk";
device = lib.mkDefault "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
@@ -44,9 +41,7 @@ let
name = "swap";
label = "swap";
size = "34G";
content = {
type = "swap";
};
content = { type = "swap"; };
};
root = {
@@ -67,20 +62,33 @@ let
})
];
# Map hostnames to their per-host module
hostModules = {
nix-laptop1 = ./nix-laptop1.nix;
};
mkHost = { hostName, system ? "x86_64-linux", extraModules ? [ ] }:
lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules =
commonModules
++ extraModules
++ [
{ networking.hostName = hostName; }
];
};
in
lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules =
commonModules
++ [ (hostModules.${hostName} or (throw "Unknown host '${hostName}' in hosts/default.nix")) ]
++ [
{ networking.hostName = hostName; }
{
nix-laptop1 = mkHost {
hostName = "nix-laptop1";
system = "x86_64-linux";
extraModules = [
./nix-laptop1.nix
];
};
# future you:
# atlas = mkHost {
# hostName = "atlas";
# system = "x86_64-linux";
# extraModules = [ ./atlas-hardware.nix ./atlas-role-server.nix ];
# };
}

View File

@@ -7,7 +7,4 @@
{
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "America/New_York";
}