roles: add role-based host composition in flake

- mkHost now takes a role list, roles resolve to ./roles/<name>.nix
- roles/core.nix = shared baseline (modules/)
- roles/k3s-server.nix = core + k3s (goyplex-vm)
- roles/hermes.nix = core + hermes (hermes-vm)
- host configuration.nix trimmed to hardware + boot + stateVersion
- optional hosts/<name>/custom.nix loads last for per-host overrides
- new hosts: one flake line + hosts/<name>/ dir
This commit is contained in:
2026-08-28 14:13:43 +00:00
parent 15b0702eb4
commit 3d15148c77
8 changed files with 49 additions and 15 deletions
+21 -7
View File
@@ -27,26 +27,40 @@
let
system = "x86_64-linux";
username = "poslop";
lib = nixpkgs.lib;
# mkHost <hostname> <role list>
# roles resolve to ./roles/<name>.nix; list entries may also be
# inline attrsets or paths, which load after (and override) roles.
# hosts/<host>/custom.nix, if present, always loads last.
mkHost =
host: modules:
name: roles:
nixpkgs.lib.nixosSystem {
modules = [ { nixpkgs.hostPlatform = system; } ] ++ modules;
modules =
[ { nixpkgs.hostPlatform = system; } ]
++ [ ./hosts/${name}/configuration.nix ]
++ map (
role:
if builtins.isString role then ./roles/${role}.nix else role
) roles
++ lib.optional (builtins.pathExists ./hosts/${name}/custom.nix)
./hosts/${name}/custom.nix;
specialArgs = {
inherit
self
inputs
username
host
;
host = name;
};
};
in
{
nixosConfigurations = {
nixos-vm2 = mkHost "nixos-vm2" [ ./hosts/nixos-vm2/configuration.nix ];
qemu-vm = mkHost "qemu-vm" [ ./hosts/qemu-vm/configuration.nix ];
goyplex-vm = mkHost "goyplex-vm" [ ./hosts/goyplex-vm/configuration.nix ];
hermes-vm = mkHost "hermes-vm" [ ./hosts/hermes-vm/configuration.nix ];
nixos-vm2 = mkHost "nixos-vm2" [ "core" ];
qemu-vm = mkHost "qemu-vm" [ "core" ];
goyplex-vm = mkHost "goyplex-vm" [ "k3s-server" ];
hermes-vm = mkHost "hermes-vm" [ "hermes" ];
};
};
}
+4 -3
View File
@@ -1,10 +1,11 @@
{ pkgs, ... }:
{
pkgs,
...
}:
{
imports = [
./hardware-configuration.nix
../../modules
../../modules/k3s/k3s.nix
];
boot.loader.systemd-boot.enable = true;
+4 -3
View File
@@ -1,10 +1,11 @@
{ pkgs, ... }:
{
pkgs,
...
}:
{
imports = [
./hardware-configuration.nix
../../modules/core
../../modules/hermes
];
boot.loader.systemd-boot.enable = true;
-1
View File
@@ -5,7 +5,6 @@
{
imports = [
./hardware-configuration.nix
../../modules
];
boot.loader.grub.enable = true;
-1
View File
@@ -5,7 +5,6 @@
{
imports = [
./hardware-configuration.nix
../../modules
];
boot.loader.grub.enable = true;
+6
View File
@@ -0,0 +1,6 @@
{
# shared baseline: core system + home manager config
imports = [
../modules
];
}
+7
View File
@@ -0,0 +1,7 @@
{
# hermes agent host: core + hermes container + secrets
imports = [
./core.nix
../modules/hermes
];
}
+7
View File
@@ -0,0 +1,7 @@
{
# k3s server node (goyplex-vm): k3s + manifests + firewall
imports = [
./core.nix
../modules/k3s/k3s.nix
];
}