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"; lazyvim-nixvim.url = "github:azuwis/lazyvim-nixvim";
}; };
outputs = inputs@{ self, nixpkgs, home-manager, disko, nixos-generators, lazyvim-nixvim, ... }: { outputs = inputs@{ self, nixpkgs, home-manager, disko, nixos-generators, lazyvim-nixvim, ... }: {
nixosConfigurations = { nixosConfigurations = import ./hosts { inherit inputs; };
"nix-laptop1" = import ./hosts {
inherit inputs;
hostName = "nix-laptop1";
};
};
}; };
} }

View File

@@ -1,11 +1,10 @@
{ inputs, hostName, system ? "x86_64-linux" }: { inputs }:
let let
nixpkgs = inputs.nixpkgs; nixpkgs = inputs.nixpkgs;
home-manager = inputs.home-manager; home-manager = inputs.home-manager;
disko = inputs.disko; disko = inputs.disko;
lib = nixpkgs.lib;
lib = nixpkgs.lib;
commonModules = [ commonModules = [
../boot.nix ../boot.nix
@@ -20,9 +19,7 @@ let
disko.devices = { disko.devices = {
disk.main = { disk.main = {
type = "disk"; type = "disk";
device = lib.mkDefault "/dev/nvme0n1"; device = lib.mkDefault "/dev/nvme0n1";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@@ -44,9 +41,7 @@ let
name = "swap"; name = "swap";
label = "swap"; label = "swap";
size = "34G"; size = "34G";
content = { content = { type = "swap"; };
type = "swap";
};
}; };
root = { root = {
@@ -67,20 +62,33 @@ let
}) })
]; ];
# Map hostnames to their per-host module mkHost = { hostName, system ? "x86_64-linux", extraModules ? [ ] }:
hostModules = { lib.nixosSystem {
nix-laptop1 = ./nix-laptop1.nix; inherit system;
};
specialArgs = { inherit inputs; };
modules =
commonModules
++ extraModules
++ [
{ networking.hostName = hostName; }
];
};
in in
lib.nixosSystem { {
inherit system; nix-laptop1 = mkHost {
hostName = "nix-laptop1";
specialArgs = { inherit inputs; }; system = "x86_64-linux";
extraModules = [
modules = ./nix-laptop1.nix
commonModules
++ [ (hostModules.${hostName} or (throw "Unknown host '${hostName}' in hosts/default.nix")) ]
++ [
{ networking.hostName = hostName; }
]; ];
};
# 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 # Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "America/New_York";
} }