refactor hosts
This commit is contained in:
@@ -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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ];
|
||||||
|
# };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user