Skip to content

Commit

Permalink
Merge pull request #164068 from cab404/master
Browse files Browse the repository at this point in the history
os-release: preserve fields from being excessively quoted
  • Loading branch information
balsoft authored Mar 16, 2022
2 parents e543cbb + 0c68e23 commit 1e49b30
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 1e49b30

Please sign in to comment.