summaryrefslogtreecommitdiffstats
path: root/nixos/modules
diff options
context:
space:
mode:
authorVladimir Serov <me@cab404.ru>2022-03-14 07:11:05 +0300
committerVladimir Serov <me@cab404.ru>2022-03-15 14:17:59 +0300
commit0c68e23f5238b60dbbd5bf994a08060bd311f89d (patch)
tree8922898f013691715af5cf0e3ce5f8824cd48109 /nixos/modules
parent976a5bc9fffaad437069df4d06edf0315f7a020f (diff)
nixos/modules/version: remove unnecessary quoting
(In cases it is unnecessary)
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/misc/version.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix
index 6c072021ed83..d825f4beb301 100644
--- a/nixos/modules/misc/version.nix
+++ b/nixos/modules/misc/version.nix
@@ -8,8 +8,12 @@ let
concatStringsSep mapAttrsToList toLower
literalExpression mkRenamedOptionModule mkDefault mkOption trivial types;
+ needsEscaping = s: null != builtins.match "[a-zA-Z0-9]+" s;
+ escapeIfNeccessary = s: if needsEscaping s then s else ''"${lib.escape [ "\$" "\"" "\\" "\`" ] s}"'';
attrsToText = attrs:
- concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}="${toString v}"'') attrs);
+ concatStringsSep "\n" (
+ mapAttrsToList (n: v: ''${n}=${escapeIfNeccessary (toString v)}'') attrs
+ );
in
{