summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2022-04-05 20:34:08 +0200
committerVladimír Čunát <v@cunat.cz>2022-04-05 20:34:08 +0200
commitb4729bad3d1c1c78dbd47634a1efba388c89dbbb (patch)
tree4ec7677a3559c38d53118bdbf7f797411741546d /pkgs/build-support
parent0e141f0382685c8ec32a28b84f6edd274ebd0ae9 (diff)
parent6427998d85dffc8d3cd724f358ed4af8e4961398 (diff)
downloadnixpkgs-b4729bad3d1c1c78dbd47634a1efba388c89dbbb.tar
nixpkgs-b4729bad3d1c1c78dbd47634a1efba388c89dbbb.tar.gz
nixpkgs-b4729bad3d1c1c78dbd47634a1efba388c89dbbb.tar.bz2
nixpkgs-b4729bad3d1c1c78dbd47634a1efba388c89dbbb.tar.lz
nixpkgs-b4729bad3d1c1c78dbd47634a1efba388c89dbbb.tar.xz
nixpkgs-b4729bad3d1c1c78dbd47634a1efba388c89dbbb.tar.zst
nixpkgs-b4729bad3d1c1c78dbd47634a1efba388c89dbbb.zip
Merge #165406: staging-next 2022-03-23
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/make-desktopitem/default.nix11
-rw-r--r--pkgs/build-support/trivial-builders.nix2
-rw-r--r--pkgs/build-support/trivial-builders/test/write-text-file.nix34
3 files changed, 38 insertions, 9 deletions
diff --git a/pkgs/build-support/make-desktopitem/default.nix b/pkgs/build-support/make-desktopitem/default.nix
index d831fe24d33..e09fd0e20f2 100644
--- a/pkgs/build-support/make-desktopitem/default.nix
+++ b/pkgs/build-support/make-desktopitem/default.nix
@@ -34,11 +34,6 @@
 , extraConfig ? {} # Additional values to be added literally to the final item, e.g. vendor extensions
 }:
 let
-  # FIXME: workaround until https://github.com/NixOS/nixpkgs/pull/162246 lands
-  cleanName = if lib.hasInfix " " name
-                then throw "makeDesktopItem: name must not contain spaces!"
-                else name;
-
   # There are multiple places in the FDO spec that make "boolean" values actually tristate,
   # e.g. StartupNotify, where "unset" is literally defined as "do something reasonable".
   # So, handle null values separately.
@@ -116,8 +111,8 @@ let
   content = [ mainSectionRendered ] ++ actionsRendered;
 in
 writeTextFile {
-  name = "${cleanName}.desktop";
-  destination = "/share/applications/${cleanName}.desktop";
+  name = "${name}.desktop";
+  destination = "/share/applications/${name}.desktop";
   text = builtins.concatStringsSep "\n" content;
-  checkPhase = "${buildPackages.desktop-file-utils}/bin/desktop-file-validate $target";
+  checkPhase = ''${buildPackages.desktop-file-utils}/bin/desktop-file-validate "$target"'';
 }
diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix
index c3072357a57..4a3d3778881 100644
--- a/pkgs/build-support/trivial-builders.nix
+++ b/pkgs/build-support/trivial-builders.nix
@@ -120,7 +120,7 @@ rec {
         allowSubstitutes = false;
       }
       ''
-        target=$out${destination}
+        target=$out${lib.escapeShellArg destination}
         mkdir -p "$(dirname "$target")"
 
         if [ -e "$textPath" ]; then
diff --git a/pkgs/build-support/trivial-builders/test/write-text-file.nix b/pkgs/build-support/trivial-builders/test/write-text-file.nix
new file mode 100644
index 00000000000..ac83a75fca4
--- /dev/null
+++ b/pkgs/build-support/trivial-builders/test/write-text-file.nix
@@ -0,0 +1,34 @@
+{ writeTextFile }:
+let
+  veryWeirdName = ''here's a name with some "bad" characters, like spaces and quotes'';
+in writeTextFile {
+  name = "weird-names";
+  destination = "/etc/${veryWeirdName}";
+  text = ''passed!'';
+  checkPhase = ''
+    # intentionally hardcode everything here, to make sure
+    # Nix does not mess with file paths
+
+    name="here's a name with some \"bad\" characters, like spaces and quotes"
+    fullPath="$out/etc/$name"
+
+    if [ -f "$fullPath" ]; then
+      echo "[PASS] File exists!"
+    else
+      echo "[FAIL] File was not created at expected path!"
+      exit 1
+    fi
+
+    content=$(<"$fullPath")
+    expected="passed!"
+
+    if [ "$content" = "$expected" ]; then
+      echo "[PASS] Contents match!"
+    else
+      echo "[FAIL] File contents don't match!"
+      echo "       Expected: $expected"
+      echo "       Got:      $content"
+      exit 2
+    fi
+  '';
+}