From f67a9a0c80e60dbe44c96ec8573ae78a35852ac4 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 30 Nov 2026 13:13:44 +0000 Subject: enstate: the system's configuration first /etc/enstate/config.json, if it exists, before --config files and arguments: the NixOS module writes the state and run directories there, so an operator's enstate finds them. --- src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 49b8558..12db84b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,6 +51,9 @@ const OPTIONS: &[OptionSpec] = &[ }, ]; +/// Read first, if it exists. +const SYSTEM_CONFIG: &str = "/etc/enstate/config.json"; + const SETTINGS: config::option::Schema = config::option::Schema { options: OPTIONS, conflicts: &[], @@ -159,7 +162,14 @@ fn main() -> ExitCode { fn run() -> Result { config::arguments::refuse_gone(std::env::args().skip(1), &SETTINGS)?; let matches = command().get_matches(); - let (layer, files) = config::arguments::merged(&matches, &SETTINGS, &[])?; + // The system's configuration, if it has one (the NixOS module writes it), then + // --config files, then arguments. + let system: Vec = [Path::new(SYSTEM_CONFIG)] + .into_iter() + .filter(|path| path.exists()) + .map(Path::to_owned) + .collect(); + let (layer, files) = config::arguments::merged(&matches, &SETTINGS, &system)?; if config::arguments::prints_config(&matches) { let settings = layer .iter() -- cgit v1.3.1