diff --git a/hermes_cli/config.py b/hermes_cli/config.py index 350d99cf8..6e86886be 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -157,7 +157,14 @@ def get_project_root() -> Path: return Path(__file__).parent.parent.resolve() def _secure_dir(path): - """Set directory to owner-only access (0700). No-op on Windows.""" + """Set directory to owner-only access (0700). No-op on Windows. + + Skipped in managed mode — the NixOS module sets group-readable + permissions (0750) so interactive users in the hermes group can + share state with the gateway service. + """ + if is_managed(): + return try: os.chmod(path, 0o700) except (OSError, NotImplementedError): @@ -165,7 +172,13 @@ def _secure_dir(path): def _secure_file(path): - """Set file to owner-only read/write (0600). No-op on Windows.""" + """Set file to owner-only read/write (0600). No-op on Windows. + + Skipped in managed mode — the NixOS activation script sets + group-readable permissions (0640) on config files. + """ + if is_managed(): + return try: if os.path.exists(str(path)): os.chmod(path, 0o600) diff --git a/nix/nixosModules.nix b/nix/nixosModules.nix index acf9a6e9d..c961aa616 100644 --- a/nix/nixosModules.nix +++ b/nix/nixosModules.nix @@ -464,7 +464,11 @@ addToSystemPackages = mkOption { type = types.bool; default = false; - description = "Add hermes CLI to environment.systemPackages."; + description = '' + Add the hermes CLI to environment.systemPackages and export + HERMES_HOME system-wide (via environment.variables) so interactive + shells share state with the gateway service. + ''; }; # ── OCI Container (opt-in) ────────────────────────────────────────── @@ -545,8 +549,12 @@ }) # ── Host CLI ────────────────────────────────────────────────────── + # Add the hermes CLI to system PATH and export HERMES_HOME system-wide + # so interactive shells share state (sessions, skills, cron) with the + # gateway service instead of creating a separate ~/.hermes/. (lib.mkIf cfg.addToSystemPackages { environment.systemPackages = [ cfg.package ]; + environment.variables.HERMES_HOME = "${cfg.stateDir}/.hermes"; }) # ── Directories ─────────────────────────────────────────────────── @@ -601,7 +609,7 @@ # so this is the single source of truth for both native and container mode. ${lib.optionalString (cfg.environment != {} || cfg.environmentFiles != []) '' ENV_FILE="${cfg.stateDir}/.hermes/.env" - install -o ${cfg.user} -g ${cfg.group} -m 0600 /dev/null "$ENV_FILE" + install -o ${cfg.user} -g ${cfg.group} -m 0640 /dev/null "$ENV_FILE" cat > "$ENV_FILE" <<'HERMES_NIX_ENV_EOF' ${envFileContent} HERMES_NIX_ENV_EOF