From 0c68e23f5238b60dbbd5bf994a08060bd311f89d Mon Sep 17 00:00:00 2001 From: Vladimir Serov Date: Mon, 14 Mar 2022 07:11:05 +0300 Subject: [PATCH] nixos/modules/version: remove unnecessary quoting (In cases it is unnecessary) --- nixos/modules/misc/version.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 {