From b9e3a29864798d55ec1d6579ab97876bb1ee9664 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 2 Mar 2023 19:22:24 +0100 Subject: [PATCH] recoll: fix generation of string lists The updated implementation will quote string lists as per the description at https://www.lesbonscomptes.com/recoll/usermanual/#RCL.INSTALL.CONFIG Fixes #3732 --- modules/services/recoll.nix | 19 ++++++++++--------- .../services/recoll/basic-configuration.conf | 12 +++++++----- .../services/recoll/basic-configuration.nix | 3 ++- .../services/recoll/config-format-order.conf | 4 ++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/services/recoll.nix b/modules/services/recoll.nix index 644b01184..794a5de8b 100644 --- a/modules/services/recoll.nix +++ b/modules/services/recoll.nix @@ -10,15 +10,16 @@ let # see the example configuration from the package (i.e., # `$out/share/recoll/examples/recoll.conf`). mkRecollConfKeyValue = generators.mkKeyValueDefault { - mkValueString = v: - if v == true then - "1" - else if v == false then - "0" - else if isList v then - concatStringsSep " " v - else - generators.mkValueStringDefault { } v; + mkValueString = let mkQuoted = v: ''"${escape [ ''"'' ] v}"''; + in v: + if v == true then + "1" + else if v == false then + "0" + else if isList v then + concatMapStringsSep " " mkQuoted v + else + generators.mkValueStringDefault { } v; } " = "; # A modified version of 'lib.generators.toINI' that also accepts top-level diff --git a/tests/modules/services/recoll/basic-configuration.conf b/tests/modules/services/recoll/basic-configuration.conf index 185768a8e..25e50c4c4 100644 --- a/tests/modules/services/recoll/basic-configuration.conf +++ b/tests/modules/services/recoll/basic-configuration.conf @@ -1,16 +1,18 @@ +dbdir = ~/.cache/recoll/xapiandb + nocjk = 0 -skippedNames+ = node_modules +skippedNames+ = "node_modules" -topdirs = ~/Downloads ~/Documents ~/library +topdirs = "~/Downloads" "~/Documents" "~/library" "~/\"cool\" files" underscoresasletter = 1 [~/library/projects] -skippedNames+ = .editorconfig .gitignore result flake.lock go.sum +skippedNames+ = ".editorconfig" ".gitignore" "result" "flake.lock" "go.sum" [~/library/projects/software] -skippedNames+ = target result +skippedNames+ = "target" "result" [~/what-is-this-project] -skippedNames+ = whoa-there +skippedNames+ = "whoa-there" diff --git a/tests/modules/services/recoll/basic-configuration.nix b/tests/modules/services/recoll/basic-configuration.nix index 9775c170c..4e6ad03e7 100644 --- a/tests/modules/services/recoll/basic-configuration.nix +++ b/tests/modules/services/recoll/basic-configuration.nix @@ -6,7 +6,8 @@ package = config.lib.test.mkStubPackage { }; configDir = "${config.xdg.configHome}/recoll"; settings = { - topdirs = [ "~/Downloads" "~/Documents" "~/library" ]; + dbdir = "~/.cache/recoll/xapiandb"; + topdirs = [ "~/Downloads" "~/Documents" "~/library" ''~/"cool" files'' ]; "skippedNames+" = [ "node_modules" ]; underscoresasletter = true; nocjk = false; diff --git a/tests/modules/services/recoll/config-format-order.conf b/tests/modules/services/recoll/config-format-order.conf index f1e251ff3..82bd27373 100644 --- a/tests/modules/services/recoll/config-format-order.conf +++ b/tests/modules/services/recoll/config-format-order.conf @@ -4,7 +4,7 @@ d = 0 e = This should be the second to the last non-attrset value in the config. -g = This is coming from a list +g = "This" "is" "coming" "from" "a" "list" [a] foo = bar @@ -18,7 +18,7 @@ b = 53 a = This should be second to the last for the attribute names with an attrset. b = 3193 c = 0 -d = Hello there +d = "Hello" "there" [foo] bar = This should be the last attribute with an attrset.