diff --git a/AGENTS.md b/AGENTS.md index 121c2a9..5c0e855 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -304,6 +304,10 @@ This provides the familiar shell/editor/CLI setup but with work git credentials | **Enter dev shell** | `nix develop` | Includes alejandra, nixd, agenix, statix, deadnix | | **Build host** | `sudo nixos-rebuild switch --flake .#m3-ares` | Replace hostname as needed | | **Dry run build** | `sudo nixos-rebuild dry-run --flake .#m3-ares` | Validate without applying | +| **Deploy servers** | `nix develop -c colmena apply --on @server` | Colmena: all hosts tagged `server` via SSH | +| **Deploy one host** | `nix develop -c colmena apply --on m3-atlas` | Colmena: single remote host | +| **Deploy this host** | `nix develop -c colmena apply-local` | Colmena: local desktop (uses sudo to activate) | +| **Preview deploy** | `nix develop -c colmena build --on m3-atlas` | Colmena: build closure without switching | | **List hosts** | `nix flake show` | Shows all NixOS configurations | | **Update flake** | `sudo nixos-rebuild switch --flake .#m3-ares --update-input nixpkgs` | Update specific input | | **Format code** | `alejandra .` | Run before committing | diff --git a/flake.lock b/flake.lock index cd69cab..3439630 100644 --- a/flake.lock +++ b/flake.lock @@ -26,7 +26,7 @@ "darwin": "darwin_2", "home-manager": "home-manager_4", "nixpkgs": "nixpkgs_4", - "systems": "systems_3" + "systems": "systems_4" }, "locked": { "lastModified": 1770165109, @@ -42,26 +42,6 @@ "type": "github" } }, - "agent-lib": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1781348569, - "narHash": "sha256-1BJtmKSqtD0CD753ZE37RgxvCJK6Iw3iKLDDaS8trY4=", - "ref": "refs/heads/master", - "rev": "75a2ed2533b4d6d8e4a34acd37e83d98d81a5fb0", - "revCount": 30, - "type": "git", - "url": "ssh://gitea@code.m3ta.dev/m3tam3re/agent-lib-legacy" - }, - "original": { - "type": "git", - "url": "ssh://gitea@code.m3ta.dev/m3tam3re/agent-lib-legacy" - } - }, "agents": { "inputs": { "nixpkgs": "nixpkgs_5" @@ -270,6 +250,29 @@ "type": "github" } }, + "colmena": { + "inputs": { + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "nixpkgs" + ], + "stable": "stable", + "systems": "systems_2" + }, + "locked": { + "lastModified": 1790716853, + "narHash": "sha256-IT0OZW81jngocoxi9Gg2CTSGOC1O6qLioW17nevqIUk=", + "owner": "nix-community", + "repo": "colmena", + "rev": "524ddd89f62721a92e8629063d347e7a1ed390de", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "colmena", + "type": "github" + } + }, "dank-qml-common": { "flake": false, "locked": { @@ -441,11 +444,11 @@ ] }, "locked": { - "lastModified": 1788450739, - "narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=", + "lastModified": 1790898470, + "narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993", + "rev": "024633cd702b10285db5cb19b40ad48d2399ba60", "type": "github" }, "original": { @@ -530,16 +533,16 @@ "uv2nix": "uv2nix" }, "locked": { - "lastModified": 1788204567, - "narHash": "sha256-Ii9xP2fKUpvCcwWZuxJ0g3CZ+IL2UZH14pUNvBfdclc=", + "lastModified": 1790244527, + "narHash": "sha256-y6NaoG+HCeMPhxRsBXrRFef4hp3FF1svSPNKpI6Xz/E=", "owner": "NousResearch", "repo": "hermes-agent", - "rev": "29112bef099274229cadff79cdff7bf7b99c4b77", + "rev": "f97608f178d1ffeca59860195ab7da295f7c8e5f", "type": "github" }, "original": { "owner": "NousResearch", - "ref": "v2026.8.31", + "ref": "v2026.9.24", "repo": "hermes-agent", "type": "github" } @@ -705,7 +708,7 @@ "rose-pine-hyprcursor", "nixpkgs" ], - "systems": "systems_4" + "systems": "systems_5" }, "locked": { "lastModified": 1709914708, @@ -726,15 +729,15 @@ "bun2nix": "bun2nix", "flake-parts": "flake-parts_2", "nixpkgs": "nixpkgs_3", - "systems": "systems_2", + "systems": "systems_3", "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1790311386, - "narHash": "sha256-bOexMr1RcAS6PFcMnEfwe5apsEoaLmSUUxlqUftd2uU=", + "lastModified": 1791089625, + "narHash": "sha256-0MHqf09PIjbpfg7KhUN/r1vGJ9OS5A2TSMq99n+Y7XU=", "owner": "numtide", "repo": "llm-agents.nix", - "rev": "1446b3cb242c8cd24619b58054112cc2d870e591", + "rev": "372f0337e8170e55ff0c017cd43ab73b02a062ad", "type": "github" }, "original": { @@ -759,17 +762,14 @@ "nur": "nur" }, "locked": { - "lastModified": 1790922417, - "narHash": "sha256-3scqz97Dg5eWH0ca7y2GHueROTuV2XGsPTSZSzKpOvE=", - "ref": "refs/heads/master", - "rev": "dfe148dc6847b5feb638d8c0e11db8b226f29a41", - "revCount": 146, - "type": "git", - "url": "ssh://gitea@code.m3ta.dev/m3tam3re/m3ta-home" + "lastModified": 1790925342, + "narHash": "sha256-kqpTlAfyAaeSbEHpM9ASBVXBWzf2BQDAODu1WXw/LTc=", + "path": "/home/m3tam3re/p/NIX/m3ta-home", + "type": "path" }, "original": { - "type": "git", - "url": "ssh://gitea@code.m3ta.dev/m3tam3re/m3ta-home" + "path": "/home/m3tam3re/p/NIX/m3ta-home", + "type": "path" } }, "m3ta-nixpkgs": { @@ -810,11 +810,11 @@ "opencode": "opencode_2" }, "locked": { - "lastModified": 1789748631, - "narHash": "sha256-XKtTXBsCcou75U5TnqfxL63ujBAGWbettPdW0XaGB80=", + "lastModified": 1791024865, + "narHash": "sha256-Jq3dpGYIg31LJK/6xfXe87RpwiKp/ldEzR7oD9YAXLM=", "ref": "refs/heads/master", - "rev": "da3c58993388ad853a2276e72a13f6c38cdf8077", - "revCount": 392, + "rev": "dd9d43bffee197301f542ddc405e6db996dbd7b3", + "revCount": 395, "type": "git", "url": "ssh://gitea@code.m3ta.dev/m3tam3re/nixpkgs" }, @@ -861,6 +861,27 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "colmena", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737420293, + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixlib": { "locked": { "lastModified": 1736643958, @@ -1055,11 +1076,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1790238896, - "narHash": "sha256-ym4BG18Pu2awiJIehla1Lo9xiB2QYRcCzW3SB74gEBY=", + "lastModified": 1790600678, + "narHash": "sha256-6k3n7X2UsZ6tAlWTz99RimiZab+17tMUrw9sRUcELiA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "34ca302a9572963c02e385c056be37c85ff51b77", + "rev": "f45c6f04c2f013f004bf94e284e95d72898d9393", "type": "github" }, "original": { @@ -1393,7 +1414,7 @@ "root": { "inputs": { "agenix": "agenix", - "agent-lib": "agent-lib", + "colmena": "colmena", "disko": "disko", "hermes-agent": "hermes-agent", "home-manager": "home-manager_3", @@ -1474,6 +1495,22 @@ "type": "github" } }, + "stable": { + "locked": { + "lastModified": 1790608446, + "narHash": "sha256-CYsYyk0zInkpQ6ojuCpvb9MahlhFXkeZpzjOU9Lxkpk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c619be20e3508300c88af8aeafeaa7017559313f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -1491,16 +1528,16 @@ }, "systems_2": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "lastModified": 1776166891, + "narHash": "sha256-bI8yrEGjrohR5hkQox7UrxDH7XqrYMwI8SL/LrJ1+S8=", "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "repo": "triplet", + "rev": "6de7bc09397911ce03636afbcf6118745ab2cda0", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default", + "repo": "triplet", "type": "github" } }, @@ -1520,6 +1557,21 @@ } }, "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_5": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", @@ -1534,7 +1586,7 @@ "type": "github" } }, - "systems_5": { + "systems_6": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -1617,7 +1669,7 @@ }, "utils": { "inputs": { - "systems": "systems_5" + "systems": "systems_6" }, "locked": { "lastModified": 1710146030, diff --git a/flake.nix b/flake.nix index 39ef4f4..d7f8cf8 100644 --- a/flake.nix +++ b/flake.nix @@ -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.." 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]; }; }); }; diff --git a/hosts/m3-kratos/home.nix b/hosts/m3-kratos/home.nix index cdeb08c..45caa04 100644 --- a/hosts/m3-kratos/home.nix +++ b/hosts/m3-kratos/home.nix @@ -53,20 +53,6 @@ in { wayland.windowManager.hyprland = { enable = true; settings = { - monitor = [ - { - output = "DP-1"; - mode = "2560x1440@144"; - position = "0x0"; - scale = 1; - } - { - output = "DP-2"; - mode = "2560x1440@144"; - position = "2560x0"; - scale = 1; - } - ]; workspace_rule = [ { workspace = "1"; diff --git a/overlays/mods/rofi-pass.nix b/overlays/mods/rofi-pass.nix index ccc6d20..2dbbc38 100644 --- a/overlays/mods/rofi-pass.nix +++ b/overlays/mods/rofi-pass.nix @@ -27,83 +27,87 @@ # backend selector backend ? "x11", }: - assert lib.assertOneOf "backend" backend [ "x11" "wayland" ]; + stdenv.mkDerivation { + pname = "rofi-pass"; + version = "2.0.2-unstable-2024-06-16"; -stdenv.mkDerivation { - pname = "rofi-pass"; - version = "2.0.2-unstable-2024-06-16"; + src = fetchFromGitHub { + owner = "carnager"; + repo = "rofi-pass"; + rev = "37c4c862deb133a85b7d72989acfdbd2ef16b8ad"; + hash = "sha256-1lPNj47vTPLBK7mVm+PngV8C/ZsjJ2EN4ffXGU2TlQo="; + }; - src = fetchFromGitHub { - owner = "carnager"; - repo = "rofi-pass"; - rev = "37c4c862deb133a85b7d72989acfdbd2ef16b8ad"; - hash = "sha256-1lPNj47vTPLBK7mVm+PngV8C/ZsjJ2EN4ffXGU2TlQo="; - }; + nativeBuildInputs = [makeBinaryWrapper]; - nativeBuildInputs = [makeBinaryWrapper]; + dontBuild = true; - dontBuild = true; + installPhase = '' + runHook preInstall - installPhase = '' - runHook preInstall + mkdir -p $out/bin + cp -a rofi-pass $out/bin/rofi-pass - mkdir -p $out/bin - cp -a rofi-pass $out/bin/rofi-pass + mkdir -p $out/share/doc/rofi-pass/ + cp -a config.example $out/share/doc/rofi-pass/config.example - mkdir -p $out/share/doc/rofi-pass/ - cp -a config.example $out/share/doc/rofi-pass/config.example + runHook postInstall + ''; - runHook postInstall - ''; + wrapperPath = lib.makeBinPath ( + [ + coreutils + findutils + gawk + gnugrep + gnused + libnotify + pwgen + rofi + util-linuxMinimal + ] + ++ lib.optionals (backend == "x11") [ + (pass.withExtensions (ext: [ext.pass-otp])) + xclip + xdotool + ] + ++ lib.optionals (backend == "wayland") [ + (pass-wayland.withExtensions (ext: [ext.pass-otp])) + wl-clipboard + wtype + ] + ); - wrapperPath = lib.makeBinPath ( - [ - coreutils - findutils - gawk - gnugrep - gnused - libnotify - pwgen - rofi - util-linuxMinimal - ] - ++ lib.optionals (backend == "x11") [ - (pass.withExtensions (ext: [ext.pass-otp])) - xclip - xdotool - ] - ++ lib.optionals (backend == "wayland") [ - (pass-wayland.withExtensions (ext: [ext.pass-otp])) - wl-clipboard - wtype - ] - ); + fixupPhase = '' + runHook preFixup - fixupPhase = '' - runHook preFixup + patchShebangs $out/bin - patchShebangs $out/bin + wrapProgram $out/bin/rofi-pass \ + --prefix PATH : "$wrapperPath" \ + --set-default ROFI_PASS_BACKEND ${ + if backend == "wayland" + then "wtype" + else "xdotool" + } \ + --set-default ROFI_PASS_CLIPBOARD_BACKEND ${ + if backend == "wayland" + then "wl-clipboard" + else "xclip" + } - wrapProgram $out/bin/rofi-pass \ - --prefix PATH : "$wrapperPath" \ - --set-default ROFI_PASS_BACKEND ${if backend == "wayland" then "wtype" else "xdotool"} \ - --set-default ROFI_PASS_CLIPBOARD_BACKEND ${ - if backend == "wayland" then "wl-clipboard" else "xclip" - } + runHook postFixup + ''; - runHook postFixup - ''; - - meta = { - description = "Script to make rofi work with password-store"; - mainProgram = "rofi-pass"; - homepage = "https://github.com/carnager/rofi-pass"; - license = lib.licenses.gpl3; - platforms = with lib.platforms; linux; - }; -} + meta = { + description = "Script to make rofi work with password-store"; + mainProgram = "rofi-pass"; + homepage = "https://github.com/carnager/rofi-pass"; + license = lib.licenses.gpl3; + platforms = with lib.platforms; linux; + }; + }