From ea20e02d61c9d3bede58d4edf42eb711e538ffe8 Mon Sep 17 00:00:00 2001 From: flpflan Date: Fri, 31 Oct 2025 23:48:17 +0800 Subject: nix/hm: prevent generation of configuration file when config is empty (#867) --- nix/hm-module.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 92f2f51..2976cf6 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -68,7 +68,7 @@ in { }; extraConfig = mkOption { type = types.str; - default = "{}"; + default = ""; description = "Caelestia CLI extra configs written to cli.json"; }; }; @@ -121,9 +121,14 @@ in { (lib.recursiveUpdate c.settings) builtins.toJSON ]; + shouldGenerate = c: c.extraConfig != "" || c.settings != {}; in { - "caelestia/shell.json".text = mkConfig cfg; - "caelestia/cli.json".text = mkConfig cfg.cli; + "caelestia/shell.json" = lib.mkIf (shouldGenerate cfg) { + text = mkConfig cfg; + }; + "caelestia/cli.json" = lib.mkIf (shouldGenerate cfg.cli) { + text = mkConfig cfg.cli; + }; }; home.packages = [shell] ++ lib.optional cfg.cli.enable cli; -- cgit v1.2.3-freya