aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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()