nix/hm: prevent generation of configuration file when config is empty (#867)

This commit is contained in:
flpflan 2025-10-31 23:48:17 +08:00 committed by GitHub
parent bfd149b256
commit ea20e02d61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,7 +68,7 @@ in {
}; };
extraConfig = mkOption { extraConfig = mkOption {
type = types.str; type = types.str;
default = "{}"; default = "";
description = "Caelestia CLI extra configs written to cli.json"; description = "Caelestia CLI extra configs written to cli.json";
}; };
}; };
@ -121,9 +121,14 @@ in {
(lib.recursiveUpdate c.settings) (lib.recursiveUpdate c.settings)
builtins.toJSON builtins.toJSON
]; ];
shouldGenerate = c: c.extraConfig != "" || c.settings != {};
in { in {
"caelestia/shell.json".text = mkConfig cfg; "caelestia/shell.json" = lib.mkIf (shouldGenerate cfg) {
"caelestia/cli.json".text = mkConfig cfg.cli; text = mkConfig cfg;
};
"caelestia/cli.json" = lib.mkIf (shouldGenerate cfg.cli) {
text = mkConfig cfg.cli;
};
}; };
home.packages = [shell] ++ lib.optional cfg.cli.enable cli; home.packages = [shell] ++ lib.optional cfg.cli.enable cli;