add claudePluginsAutoUpdate NixOS option, default false

This commit is contained in:
damocles 2026-05-17 02:22:04 +02:00
parent 6652ae90ab
commit ca86bcf4bd
2 changed files with 31 additions and 1 deletions

View file

@ -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 <source>`. 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::<bool>(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])