From 600f39f966459e571c881f0e4f4af16b4eb16329 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 28 Jun 2020 00:41:05 +0200 Subject: [PATCH] xresources: do not generate file for empty properties --- modules/xresources.nix | 25 +++++++++++++------------ tests/modules/xresources/default.nix | 5 ++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/modules/xresources.nix b/modules/xresources.nix index e9e131352..dc59e50c4 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -75,17 +75,18 @@ in { }; }; - config = mkIf (cfg.properties != null || cfg.extraConfig != "") { - home.file.".Xresources" = { - text = concatStringsSep "\n" ([ ] - ++ optional (cfg.extraConfig != "") cfg.extraConfig - ++ optionals (cfg.properties != null) - (mapAttrsToList formatLine cfg.properties)) + "\n"; - onChange = '' - if [[ -v DISPLAY ]] ; then - $DRY_RUN_CMD ${pkgs.xorg.xrdb}/bin/xrdb -merge $HOME/.Xresources - fi - ''; + config = mkIf ((cfg.properties != null && cfg.properties != { }) + || cfg.extraConfig != "") { + home.file.".Xresources" = { + text = concatStringsSep "\n" ([ ] + ++ optional (cfg.extraConfig != "") cfg.extraConfig + ++ optionals (cfg.properties != null) + (mapAttrsToList formatLine cfg.properties)) + "\n"; + onChange = '' + if [[ -v DISPLAY ]] ; then + $DRY_RUN_CMD ${pkgs.xorg.xrdb}/bin/xrdb -merge $HOME/.Xresources + fi + ''; + }; }; - }; } diff --git a/tests/modules/xresources/default.nix b/tests/modules/xresources/default.nix index afd15fbd3..70b3e6b4a 100644 --- a/tests/modules/xresources/default.nix +++ b/tests/modules/xresources/default.nix @@ -1 +1,4 @@ -{ xresources = ./xresources.nix; } +{ + xresources = ./xresources.nix; + xresources-empty-properties = ./empty.nix; +}