aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 13:13:44 +0000
committertv <tv@krebsco.de>2026-11-30 14:59:15 +0000
commitf67a9a0c80e60dbe44c96ec8573ae78a35852ac4 (patch)
treef3d5408db3085b0fb2ebe75306350c0cf9122a22 /src
parentac214a023e3d823a8231c365656cfa27703f27d5 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs12
1 files changed, 11 insertions, 1 deletions
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<ExitCode> {
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<PathBuf> = [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()