From cf80199bfcbcecf6be84fea122c66fc081c4edd3 Mon Sep 17 00:00:00 2001
From: Roman Volosatovs <rvolosatovs@riseup.net>
Date: Sun, 22 Jul 2018 20:57:01 +0200
Subject: [PATCH] xresources: join lists with a ","

---
 modules/xresources.nix | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/modules/xresources.nix b/modules/xresources.nix
index 634314f3a..7afee8bb7 100644
--- a/modules/xresources.nix
+++ b/modules/xresources.nix
@@ -8,11 +8,17 @@ let
 
   formatLine = n: v:
     let
-      v' =
+      formatList = x:
+        if isList x
+        then throw "can not convert 2-dimensional lists to Xresources format"
+        else formatValue x;
+
+      formatValue = v:
         if isBool v then (if v then "true" else "false")
+        else if isList v then concatMapStringsSep ", " formatList v
         else toString v;
     in
-      "${n}: ${v'}";
+      "${n}: ${formatValue v}";
 
 in
 
@@ -24,11 +30,16 @@ in
       type = types.nullOr types.attrs;
       default = null;
       example = {
-        "XTerm*faceName" = "dejavu sans mono";
         "Emacs*toolBar" = 0;
+        "XTerm*faceName" = "dejavu sans mono";
+        "XTerm*charClass" = [ "37:48" "45-47:48" "58:48" "64:48" "126:48" ];
       };
       description = ''
         X server resources that should be set.
+        Booleans are formatted as "true" or "false" respectively.
+        List elements are recursively formatted as a string and joined by commas.
+        All other values are directly formatted using builtins.toString. 
+        Note, that 2-dimensional lists are not supported and specifying one will throw an exception.
         If this and all other xresources options are
         <code>null</code>, then this feature is disabled and no
         <filename>~/.Xresources</filename> link is produced.