From ca86bcf4bd77e0e77c7c56343922b3763add1155 Mon Sep 17 00:00:00 2001 From: damocles Date: Sun, 17 May 2026 02:22:04 +0200 Subject: [PATCH] add claudePluginsAutoUpdate NixOS option, default false --- hive-ag3nt/src/plugins.rs | 16 +++++++++++++++- nix/templates/harness-base.nix | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/hive-ag3nt/src/plugins.rs b/hive-ag3nt/src/plugins.rs index 7530656..baea363 100644 --- a/hive-ag3nt/src/plugins.rs +++ b/hive-ag3nt/src/plugins.rs @@ -19,6 +19,7 @@ use crate::client; const PLUGINS_PATH: &str = "/etc/hyperhive/claude-plugins.json"; const MARKETPLACES_PATH: &str = "/etc/hyperhive/claude-marketplaces.json"; +const AUTO_UPDATE_PATH: &str = "/etc/hyperhive/claude-plugins-auto-update.json"; /// Add every marketplace from `/etc/hyperhive/claude-marketplaces.json` /// via `claude plugin marketplace add `. Idempotent: re-add of @@ -66,6 +67,15 @@ async fn add_marketplaces() { } } +/// Read the `hyperhive.claudePluginsAutoUpdate` flag written by the NixOS +/// module. Defaults to `false` when the file is absent or unparseable. +async fn auto_update_enabled() -> bool { + match tokio::fs::read_to_string(AUTO_UPDATE_PATH).await { + Ok(s) => serde_json::from_str::(s.trim()).unwrap_or(false), + Err(_) => false, + } +} + /// Update all configured plugin marketplaces. Non-fatal — logs a warning /// on failure but does not abort the install sequence. async fn update_marketplaces() { @@ -112,7 +122,11 @@ pub async fn install_configured(socket: &Path, notify_recipient: Option<&str>) { return; } add_marketplaces().await; - update_marketplaces().await; + if auto_update_enabled().await { + update_marketplaces().await; + } else { + tracing::debug!("claudePluginsAutoUpdate=false, skipping marketplace update"); + } for spec in specs { match Command::new("claude") .args(["plugin", "install", &spec]) diff --git a/nix/templates/harness-base.nix b/nix/templates/harness-base.nix index 8b43e7a..5dea0e2 100644 --- a/nix/templates/harness-base.nix +++ b/nix/templates/harness-base.nix @@ -149,6 +149,19 @@ ''; }; + options.hyperhive.claudePluginsAutoUpdate = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + When true, the harness runs `claude plugin marketplace update` + before installing plugins at boot, pulling the latest index from + all configured marketplaces. Disabled by default — most agents + want pinned plugin versions and the network round-trip adds to + boot time. Enable for agents that should always install the latest + available version of their plugins. + ''; + }; + config = { environment.etc."hyperhive/extra-mcp.json".text = builtins.toJSON config.hyperhive.extraMcpServers; @@ -161,6 +174,9 @@ environment.etc."hyperhive/claude-marketplaces.json".text = builtins.toJSON config.hyperhive.claudeMarketplaces; + environment.etc."hyperhive/claude-plugins-auto-update.json".text = + builtins.toJSON config.hyperhive.claudePluginsAutoUpdate; + boot.isNspawnContainer = true; # `claude-code` is unfree. Each per-agent container's nixosConfiguration