From 46dc2e5d9f55164d28705facd0f9a3b4c0d2807a Mon Sep 17 00:00:00 2001 From: polykernel <81340136+polykernel@users.noreply.github.com> Date: Sun, 20 Mar 2022 16:22:56 -0400 Subject: [PATCH] gtk: fix missing newline in formatted config (#2809) The conversion from `concatMapStrings` to `concatStringsSep` introduced in https://github.com/nix-community/home-manager/pull/2481 creates an unintended behavior change where the formatted config does not end in a newline.[1] This is problematic for manipulation at the Nix level. In particular, this cause a regression in the generation of gtk2 settings due to concatenated of the formatted config and `gtk2.extraConfig` without a newline in between. This commit restores `concatMapStrings` to match the previous behavior and adds a newline to the final string for the generated gtk2 config. The test case for gtk2-basic-config was also updated to check behavior at concatenation boundaries. [1] - https://github.com/nix-community/home-manager/pull/2481#discussion_r830648706 --- modules/misc/gtk.nix | 6 +++--- tests/modules/misc/gtk/gtk2-basic-config-expected.conf | 3 ++- tests/modules/misc/gtk/gtk2-basic-config.nix | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 0cc9146d8..6687a33be 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -250,8 +250,8 @@ in { ]; home.file.${cfg2.configLocation}.text = - concatStringsSep "\n" (mapAttrsToList formatGtk2Option gtkIni) - + cfg2.extraConfig; + concatMapStrings (l: l + "\n") (mapAttrsToList formatGtk2Option gtkIni) + + cfg2.extraConfig + "\n"; home.sessionVariables.GTK2_RC_FILES = cfg2.configLocation; @@ -262,7 +262,7 @@ in { mkIf (cfg3.extraCss != "") { text = cfg3.extraCss; }; xdg.configFile."gtk-3.0/bookmarks" = mkIf (cfg3.bookmarks != [ ]) { - text = concatStringsSep "\n" cfg3.bookmarks; + text = concatMapStrings (l: l + "\n") cfg3.bookmarks; }; xdg.configFile."gtk-4.0/settings.ini".text = diff --git a/tests/modules/misc/gtk/gtk2-basic-config-expected.conf b/tests/modules/misc/gtk/gtk2-basic-config-expected.conf index 2e4c1c368..4096a8477 100644 --- a/tests/modules/misc/gtk/gtk2-basic-config-expected.conf +++ b/tests/modules/misc/gtk/gtk2-basic-config-expected.conf @@ -1 +1,2 @@ -gtk-can-change-accels = 1 \ No newline at end of file +gtk-theme-name = "Adwaita" +gtk-can-change-accels = 1 diff --git a/tests/modules/misc/gtk/gtk2-basic-config.nix b/tests/modules/misc/gtk/gtk2-basic-config.nix index 228b5478d..5671ac93e 100644 --- a/tests/modules/misc/gtk/gtk2-basic-config.nix +++ b/tests/modules/misc/gtk/gtk2-basic-config.nix @@ -6,6 +6,7 @@ with lib; config = { gtk = { enable = true; + theme.name = "Adwaita"; gtk2.extraConfig = "gtk-can-change-accels = 1"; };