The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(nix): fresh declarative installs no longer warn their config predates version 12 (#126022)
Siddharth Balyan298df0820d6a
diff --git a/nix/checks.nix b/nix/checks.nixindex e280818425e..72ab72003c3 100644--- a/nix/checks.nix+++ b/nix/checks.nix@@ -1361,6 +1361,39 @@ json.dump(sorted(leaf_paths(DEFAULT_CONFIG)), sys.stdout, indent=2)echo "ok" > $out/result'';+ # A fresh declarative install must be current to the Hermes it ships+ # with. Hermes cannot stamp config.yaml in managed mode, so an+ # unstamped file reads as version 0 and trips the support-floor+ # warning at every boot.+ generated-config-version =+ let+ common = import ./moduleCommon.nix { inherit lib; };+ configFiles = common.mkConfigFiles {+ inherit pkgs;+ cfg = {+ package = hermes-agent;+ extraPythonPackages = [ ];+ extraDependencyGroups = [ ];+ configFile = null;+ settings.model.default = "test/nix-model";+ };+ workingDirectory = "/var/lib/hermes/workspace";+ };+ in+ pkgs.runCommand "hermes-generated-config-version" { } ''+ set -e+ export HOME=$(mktemp -d) HERMES_HOME=$(mktemp -d)+ ${configMergeScript} ${configFiles.generated} "$HERMES_HOME/config.yaml"+ ${hermesVenv}/bin/python3 -c '+ from hermes_cli.config import check_config_version+ current, latest = check_config_version(raise_on_parse_error=True)+ assert current == latest, f"generated config.yaml reads as v{current}, package is v{latest}"+ print(f"PASS: generated config.yaml is at v{current}")+ '+ mkdir -p $out+ echo "ok" > $out/result+ '';+# ── Config merge + round-trip test ────────────────────────────────# Tests the merge script (Nix activation behavior) across 7# scenarios, then verifies Python's load_config() reads correctly.diff --git a/nix/moduleCommon.nix b/nix/moduleCommon.nixindex c75ee383c12..5dfeb88ad5f 100644--- a/nix/moduleCommon.nix+++ b/nix/moduleCommon.nix@@ -688,6 +688,11 @@ let# terminal.cwd replaces the old MESSAGING_CWD environment variable. The# order of the recursiveUpdate lets an explicit settings.terminal.cwd# replace the default value.+ #+ # The file also carries the `_config_version` of the package. In managed+ # mode Hermes refuses to write config.yaml, so it cannot stamp the version+ # itself, and an unstamped file reads as version 0 at every boot. The build+ # reads the version from DEFAULT_CONFIG so it always matches the package.mkConfigFiles ={pkgs,@@ -695,9 +700,22 @@ letworkingDirectory,}:let- generated = pkgs.writeText "hermes-config.yaml" (- builtins.toJSON (lib.recursiveUpdate { terminal.cwd = workingDirectory; } cfg.settings)- );+ generated =+ pkgs.runCommand "hermes-config.yaml"+ {+ settings = builtins.toJSON (lib.recursiveUpdate { terminal.cwd = workingDirectory; } cfg.settings);+ passAsFile = [ "settings" ];+ }+ ''+ HOME=$TMPDIR ${(effectivePackage cfg).hermesVenv}/bin/python3 - "$settingsPath" > $out <<'PY'+ import json, sys+ from hermes_cli.config_defaults import DEFAULT_CONFIG+ with open(sys.argv[1]) as f:+ settings = json.load(f)+ settings.setdefault("_config_version", DEFAULT_CONFIG["_config_version"])+ json.dump(settings, sys.stdout)+ PY+ '';in{inherit generated;