From b3a1e80f6f967c1c77f1be47cb0a0ae438e912ab Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 9 Mar 2026 18:42:43 +0100 Subject: [PATCH] allow custom pre-setup config options --- README.md | 1 + nix/hm-module.nix | 9 ++++++++- nix/image/configs/nc/config.php | 4 ++-- src/cloud.rs | 12 ++++++++++-- src/config.rs | 4 ++++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3bb98ca..0ad77bc 100644 --- a/README.md +++ b/README.md @@ -321,6 +321,7 @@ disable_apps = ["contacts"] # apps to disable after setup, defaults to [] post_setup = [# commands to execute after setup, defaults to [] "occ group:add test", ] +config = { "foo" = "bar" } # configuration options to set before install [[volume]] # optional source = "/tmp/haze-shared" diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 072fda4..7fe684d 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -12,7 +12,7 @@ with lib; let app_directories = cfg.appDirectories; work_dir = cfg.workDir; auto_setup = { - enabled = cfg.autoSetup.enable; + inherit (cfg.autoSetup) enable config; post_setup = cfg.autoSetup.postSetup; enable_apps = cfg.autoSetup.enableApps; disable_apps = cfg.autoSetup.disableApps; @@ -91,6 +91,13 @@ in { default = []; description = "Commands to run post-setup"; }; + config = mkOption { + type = types.submodule { + freeformType = format.type; + }; + description = "Configuration options to set before install"; + default = {}; + }; }; }; }; diff --git a/nix/image/configs/nc/config.php b/nix/image/configs/nc/config.php index b00d47b..06de6db 100644 --- a/nix/image/configs/nc/config.php +++ b/nix/image/configs/nc/config.php @@ -9,8 +9,8 @@ if (file_exists(__DIR__ . '/nextcloud.json')) { $CONFIG = array_merge_recursive($extra_config, [ 'debug' => true, 'memcache.local' => '\\OC\\Memcache\\APCu', - 'memcache.distributed' => '\\OC\\Memcache\\APCu', - 'memcache.locking' => '\\OC\\Memcache\\APCu', + 'memcache.distributed' => '\\OC\\Memcache\\Redis', + 'memcache.locking' => '\\OC\\Memcache\\Redis', 'allow_local_remote_servers' => true, 'trusted_domains' => ['cloud'], 'profiling.secret' => 'haze', diff --git a/src/cloud.rs b/src/cloud.rs index 8437d63..0c52e13 100644 --- a/src/cloud.rs +++ b/src/cloud.rs @@ -15,7 +15,7 @@ use flate2::read::GzDecoder; use futures_util::future::try_join_all; use miette::{IntoDiagnostic, Report, Result, WrapErr}; use petname::petname; -use serde_json::{Map, Value}; +use serde_json::Value; use std::borrow::Cow; use std::collections::HashMap; use std::fmt::Display; @@ -297,7 +297,15 @@ impl Cloud { .wrap_err_with(|| format!("Failed to setup work directory {}", mapping.source))?; } - let mut nc_config = Value::Object(Map::new()); + let mut nc_config = Value::Object( + config + .auto_setup + .config + .clone() + .into_iter() + .map(|(key, value)| (key, serde_json::to_value(value).unwrap())) + .collect(), + ); nc_config["apps_paths"] = Value::Array( once("apps") .chain( diff --git a/src/config.rs b/src/config.rs index b790b52..9e4548f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,7 @@ use std::convert::TryFrom; use std::env::home_dir; use std::fs::read_to_string; use std::net::IpAddr; +use toml::map::Map; use toml::Value; #[derive(Debug, Deserialize, Default)] @@ -87,6 +88,8 @@ pub struct HazeAutoSetupConfig { pub disable_apps: Vec, #[serde(default)] pub post_setup: Vec, + #[serde(default)] + pub config: Map, } impl Default for HazeAutoSetupConfig { @@ -98,6 +101,7 @@ impl Default for HazeAutoSetupConfig { enable_apps: Vec::default(), disable_apps: Vec::default(), post_setup: Vec::default(), + config: Map::default(), } } }