diff options
author | Alexander Bantyev <balsoft@balsoft.ru> | 2022-03-16 07:46:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 07:46:16 +0300 |
commit | 1e49b301b97153c32d041675537cd03f0ee90510 (patch) | |
tree | 67844f2642c159ec7c8a2dbe0da7d76c87ccfd80 /nixos | |
parent | e543cbb77ece4ce53aa1056ceae8b9f6b2e8c0f6 (diff) | |
parent | 0c68e23f5238b60dbbd5bf994a08060bd311f89d (diff) | |
download | nixpkgs-1e49b301b97153c32d041675537cd03f0ee90510.tar nixpkgs-1e49b301b97153c32d041675537cd03f0ee90510.tar.gz nixpkgs-1e49b301b97153c32d041675537cd03f0ee90510.tar.bz2 nixpkgs-1e49b301b97153c32d041675537cd03f0ee90510.tar.lz nixpkgs-1e49b301b97153c32d041675537cd03f0ee90510.tar.xz nixpkgs-1e49b301b97153c32d041675537cd03f0ee90510.tar.zst nixpkgs-1e49b301b97153c32d041675537cd03f0ee90510.zip |
Merge pull request #164068 from cab404/master
os-release: preserve fields from being excessively quoted
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/misc/version.nix | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 6c072021ed8..d825f4beb30 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 { |