summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2022-10-09 12:02:02 +0000
committerGitHub <noreply@github.com>2022-10-09 12:02:02 +0000
commit3e675d06f5f236e84a90ccd4d993d1784d043b4f (patch)
treec2368cf61f93e08d2adb0394cdf588a632b1e4c1 /nixos/lib
parentef30dee2d6e0317bbdca083ffc2587e4f0895711 (diff)
parent8972888c554bd9eafcaf5c17551adc606bba686d (diff)
downloadnixpkgs-3e675d06f5f236e84a90ccd4d993d1784d043b4f.tar
nixpkgs-3e675d06f5f236e84a90ccd4d993d1784d043b4f.tar.gz
nixpkgs-3e675d06f5f236e84a90ccd4d993d1784d043b4f.tar.bz2
nixpkgs-3e675d06f5f236e84a90ccd4d993d1784d043b4f.tar.lz
nixpkgs-3e675d06f5f236e84a90ccd4d993d1784d043b4f.tar.xz
nixpkgs-3e675d06f5f236e84a90ccd4d993d1784d043b4f.tar.zst
nixpkgs-3e675d06f5f236e84a90ccd4d993d1784d043b4f.zip
Merge staging-next into staging
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/utils.nix14
1 files changed, 9 insertions, 5 deletions
diff --git a/nixos/lib/utils.nix b/nixos/lib/utils.nix
index d7671a37499..f646f70323e 100644
--- a/nixos/lib/utils.nix
+++ b/nixos/lib/utils.nix
@@ -102,7 +102,11 @@ rec {
         if item ? ${attr} then
           nameValuePair prefix item.${attr}
         else if isAttrs item then
-          map (name: recurse (prefix + "." + name) item.${name}) (attrNames item)
+          map (name:
+            let
+              escapedName = ''"${replaceChars [''"'' "\\"] [''\"'' "\\\\"] name}"'';
+            in
+              recurse (prefix + "." + escapedName) item.${name}) (attrNames item)
         else if isList item then
           imap0 (index: item: recurse (prefix + "[${toString index}]") item) item
         else
@@ -182,13 +186,13 @@ rec {
                 '')
                (attrNames secrets))
     + "\n"
-    + "${pkgs.jq}/bin/jq >'${output}' '"
-    + concatStringsSep
+    + "${pkgs.jq}/bin/jq >'${output}' "
+    + lib.escapeShellArg (concatStringsSep
       " | "
       (imap1 (index: name: ''${name} = $ENV.secret${toString index}'')
-             (attrNames secrets))
+             (attrNames secrets)))
     + ''
-      ' <<'EOF'
+       <<'EOF'
       ${builtins.toJSON set}
       EOF
       (( ! $inherit_errexit_enabled )) && shopt -u inherit_errexit