diff options
| -rw-r--r-- | configs/hermes.nix | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/configs/hermes.nix b/configs/hermes.nix index 2cf40e9..a4e5b4e 100644 --- a/configs/hermes.nix +++ b/configs/hermes.nix @@ -4,21 +4,47 @@ { config, lib, pkgs, ... }: let tmux = "${pkgs.tmux}/bin/tmux -S /run/hermes/tmux"; - # Not a flake input: flake-compat evaluates hermes-agent's flake, with its - # flake.lock, using plain nix. Bump rev and sha256 together. - flake-compat = builtins.fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/5edf11c44bc78a0d334f6334cdaf7d60d732daab.tar.gz"; - sha256 = "0yqfa6rx8md81bcn4szfp0hjq2f3h9i8zjzhqqyfqdkrj5559nmw"; + + # Bump url and sha256 together. + src = builtins.fetchTarball { + url = "https://github.com/NousResearch/hermes-agent/archive/9f47677483d1b4de4d1a88d37b3b7ca18b18b215.tar.gz"; + sha256 = "1xpvwgmn5slmfc2zsr5bfgywz1c6dqx3i5qy6ppbdvg1j2vngx71"; }; - hermes-agent = (import flake-compat { - src = builtins.fetchTarball { - url = "https://github.com/NousResearch/hermes-agent/archive/9f47677483d1b4de4d1a88d37b3b7ca18b18b215.tar.gz"; - sha256 = "1xpvwgmn5slmfc2zsr5bfgywz1c6dqx3i5qy6ppbdvg1j2vngx71"; + + # hermes-agent's flake without flakes, like flake-compat, but with this + # system's pkgs as nixpkgs, which all of the flake's inputs follow. The + # other inputs are fetched as locked in its flake.lock; home-manager is + # left out, as only the flake's checks use it. + callFlake = src: inputs: + let + self = { _type = "flake"; outPath = src; inherit inputs; } + // (import (src + "/flake.nix")).outputs (inputs // { inherit self; }); + in + self; + input = name: + let locked = (builtins.fromJSON (builtins.readFile (src + "/flake.lock"))).nodes.${name}.locked; + in builtins.fetchTarball { + url = "https://github.com/${locked.owner}/${locked.repo}/archive/${locked.rev}.tar.gz"; + sha256 = locked.narHash; }; - }).defaultNix; + nixpkgs = { + _type = "flake"; + outPath = pkgs.path; + inherit (pkgs) lib; + legacyPackages.${pkgs.stdenv.hostPlatform.system} = pkgs; + }; + pyproject-nix = callFlake (input "pyproject-nix") { inherit nixpkgs; }; + uv2nix = callFlake (input "uv2nix") { inherit nixpkgs pyproject-nix; }; + hermes-agent = callFlake src { + inherit nixpkgs pyproject-nix uv2nix; + flake-parts = callFlake (input "flake-parts") { nixpkgs-lib = nixpkgs; }; + pyproject-build-systems = callFlake (input "pyproject-build-systems") { inherit nixpkgs pyproject-nix uv2nix; }; + }; in { - imports = [ hermes-agent.nixosModules.default ]; + # Straight from the file, as the flake's nixosModules.default needs pkgs, + # which imports can't use. + imports = [ (import (src + "/nix/nixosModules.nix") { inputs.self = hermes-agent; }).flake.nixosModules.default ]; services.hermes-agent = { enable = true; |
