Skip to content

Commit

Permalink
nixos/modules/version: remove unnecessary quoting
Browse files Browse the repository at this point in the history
(In cases it is unnecessary)
  • Loading branch information
cab404 committed Mar 15, 2022
1 parent 976a5bc commit 0c68e23
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nixos/modules/misc/version.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 0c68e23

Please sign in to comment.