Files
rice-flakes/flake.nix
T
poslop 3d15148c77 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
2026-08-28 14:13:43 +00:00

67 lines
1.7 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
hyprland.url = "github:hyprwm/Hyprland";
hermes-agent.url = "github:NousResearch/hermes-agent";
agenix.url = "github:ryantm/agenix";
hjem = {
url = "github:feel-co/hjem";
inputs.nixpkgs.follows = "nixpkgs";
};
hjem-rum = {
url = "github:snugnug/hjem-rum";
inputs.nixpkgs.follows = "nixpkgs";
inputs.hjem.follows = "hjem";
};
};
outputs =
{
self,
nixpkgs,
...
}@inputs:
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 =
name: roles:
nixpkgs.lib.nixosSystem {
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 = name;
};
};
in
{
nixosConfigurations = {
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" ];
};
};
}