feat(colmena): set up Colmena as deploy tool for all NixOS hosts

- Add colmena flake input (nix-community >= 0.5.0) and CLI to devShell
- Extract shared nixosHosts module map consumed by BOTH
  nixosConfigurations (nixos-rebuild/nh) and the Colmena hive,
  so local rebuilds and remote deploys cannot drift apart
- Add colmenaHive output via colmena.lib.makeHive (direct flake
  evaluation, required on Nix >= 2.21) plus legacy colmena output
- Tags: m3-atlas/m3-helios/m3-hermes = server, m3-ares/m3-kratos =
  desktop with allowLocalDeployment; targetUser m3tam3re
- meta.allowApplyAll = false guards bare 'colmena apply'; use
  'colmena apply --on @server' or 'apply-local' instead
- Document deploy commands in AGENTS.md

Note: colmena builds render system.nixos.version as 26.11pre-git
(colmena's evaluator has no flake sourceInfo) - cosmetic only,
package closures are identical to nixos-rebuild.

Includes pending working-tree changes: hermes-agent bump v2026.9.24,
agent-lib input removal, m3ta-home switched to local path checkout,
m3-kratos monitor setup update, alejandra reformat of rofi-pass.nix.
This commit is contained in:
m3ta-chiron committed 2026-10-04 13:07:14 +02:00
1 parent 8a083656eb
commit db0bfbc707
5 files changed
+310 -182

No files matched your search

+130 -48
View File
@@ -30,10 +30,10 @@
# Nix library for rendering agent skill source selections into store
# dirs (mkHermesSkillsDir). Consumed directly by hosts/m3-hermes.
agent-lib = {
url = "git+ssh://gitea@code.m3ta.dev/m3tam3re/agent-lib-legacy";
inputs.nixpkgs.follows = "nixpkgs";
};
# agent-lib = {
# url = "git+ssh://gitea@code.m3ta.dev/m3tam3re/agent-lib-legacy";
# inputs.nixpkgs.follows = "nixpkgs";
# };
llm-agents.url = "github:numtide/llm-agents.nix";
@@ -43,6 +43,13 @@
};
agenix.url = "github:ryantm/agenix";
# Deployment tool (colmena >= 0.5.0 reads the colmenaHive output).
# Also provides colmena.lib.makeHive used by our flake outputs.
colmena = {
url = "github:nix-community/colmena";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
@@ -54,17 +61,18 @@
nix-colors.url = "github:misterio77/nix-colors";
m3ta-home = {
url = "git+ssh://gitea@code.m3ta.dev/m3tam3re/m3ta-home";
# url = "path:/home/m3tam3re/p/NIX/m3ta-home";
# url = "git+ssh://gitea@code.m3ta.dev/m3tam3re/m3ta-home";
url = "path:/home/m3tam3re/p/NIX/m3ta-home";
inputs.nixpkgs.follows = "nixpkgs";
};
hermes-agent.url = "github:NousResearch/hermes-agent/v2026.8.31";
hermes-agent.url = "github:NousResearch/hermes-agent/v2026.9.24";
};
outputs = {
self,
agenix,
colmena,
home-manager,
nixpkgs,
m3ta-nixpkgs,
@@ -81,19 +89,13 @@
];
forAllSystems = nixpkgs.lib.genAttrs systems;
allOverlays = import ./overlays {inherit inputs outputs;};
in {
packages =
forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
overlays = allOverlays;
homeManagerModules = import ./modules/home-manager;
nixosConfigurations = {
m3-ares = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs;
system = "x86_64-linux";
hostname = "m3-ares";
};
# Single source of truth for all NixOS hosts. Consumed by both
# nixosConfigurations (nixos-rebuild/nh) and the Colmena hive below,
# so local rebuilds and remote deploys can never drift apart.
nixosHosts = {
m3-ares = {
hostname = "m3-ares";
modules = [
./hosts/m3-ares
agenix.nixosModules.default
@@ -101,11 +103,7 @@
inputs.hermes-agent.nixosModules.default
];
};
m3-atlas = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs;
system = "x86_64-linux";
};
m3-atlas = {
modules = [
./hosts/m3-atlas
inputs.disko.nixosModules.disko
@@ -113,12 +111,8 @@
m3ta-nixpkgs.nixosModules.default
];
};
m3-kratos = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs;
system = "x86_64-linux";
hostname = "m3-kratos";
};
m3-kratos = {
hostname = "m3-kratos";
modules = [
./hosts/m3-kratos
agenix.nixosModules.default
@@ -127,11 +121,7 @@
inputs.hermes-agent.nixosModules.default
];
};
m3-helios = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs;
system = "x86_64-linux";
};
m3-helios = {
modules = [
./hosts/m3-helios
inputs.disko.nixosModules.disko
@@ -139,11 +129,7 @@
m3ta-nixpkgs.nixosModules.default
];
};
m3-hermes = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs;
system = "x86_64-linux";
};
m3-hermes = {
modules = [
./hosts/m3-hermes
inputs.disko.nixosModules.disko
@@ -153,6 +139,100 @@
];
};
};
mkSpecialArgs = hostname:
{
inherit inputs outputs;
system = "x86_64-linux";
}
// nixpkgs.lib.optionalAttrs (hostname != null) {inherit hostname;};
# Colmena deployment hive (https://colmena.cli.rs):
# nix develop -c colmena apply --on @server # all servers via SSH
# nix develop -c colmena apply --on m3-atlas # single host
# nix develop -c colmena apply-local # this machine (desktops)
# meta.nixpkgs overlays/config are merged with mkBefore, so the overlays
# set in hosts/common/default.nix keep working unchanged.
rawHive = {
meta = {
# NOTE: Colmena imports nixpkgs without flake sourceInfo, so
# system.nixos.version renders as "26.11pre-git" instead of
# "26.11.<date>.<rev>" under `colmena` builds. Purely cosmetic
# (os-release) — package closure, overlays and options are identical
# to nixosConfigurations. Documented colmena behavior.
nixpkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [];
}; specialArgs = mkSpecialArgs null;
nodeSpecialArgs =
nixpkgs.lib.mapAttrs
(_: host: mkSpecialArgs host.hostname)
(nixpkgs.lib.filterAttrs (_: host: host ? hostname) nixosHosts);
# Guard against bare `colmena apply` hitting every node (including
# desktops in active use). Use --on filters or apply-local instead.
allowApplyAll = false;
};
defaults = {
deployment.targetUser = "m3tam3re";
};
m3-ares = {
imports = nixosHosts.m3-ares.modules;
deployment = {
targetHost = "m3-ares";
tags = ["desktop"];
allowLocalDeployment = true;
};
};
m3-atlas = {
imports = nixosHosts.m3-atlas.modules;
deployment = {
targetHost = "m3-atlas";
tags = ["server"];
};
};
m3-kratos = {
imports = nixosHosts.m3-kratos.modules;
deployment = {
targetHost = "m3-kratos";
tags = ["desktop"];
allowLocalDeployment = true;
};
};
m3-helios = {
imports = nixosHosts.m3-helios.modules;
deployment = {
targetHost = "m3-helios";
tags = ["server"];
};
};
m3-hermes = {
imports = nixosHosts.m3-hermes.modules;
deployment = {
targetHost = "m3-hermes";
tags = ["server"];
};
};
};
in {
packages =
forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
overlays = allOverlays;
homeManagerModules = import ./modules/home-manager;
nixosConfigurations =
nixpkgs.lib.mapAttrs
(_: host:
nixpkgs.lib.nixosSystem {
specialArgs = mkSpecialArgs (host.hostname or null);
modules = host.modules;
})
nixosHosts;
# Colmena >= 0.5.0 (direct flake evaluation) and legacy CLIs alike.
colmenaHive = colmena.lib.makeHive rawHive;
colmena = rawHive;
homeConfigurations = {
"m3tam3re@m3-daedalus" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."x86_64-linux";
@@ -171,14 +251,16 @@
};
in {
default = pkgs.mkShell {
buildInputs = with pkgs; [
alejandra
nixd
openssh
agenix.packages.${system}.default
statix
deadnix
];
buildInputs = with pkgs;
[
alejandra
nixd
openssh
agenix.packages.${system}.default
statix
deadnix
]
++ [colmena.packages.${system}.default];
};
});
};