summary refs log tree commit diff
path: root/pkgs/build-support/fetchhg/nix-prefetch-hg
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/fetchhg/nix-prefetch-hg')
-rwxr-xr-xpkgs/build-support/fetchhg/nix-prefetch-hg7
1 files changed, 3 insertions, 4 deletions
diff --git a/pkgs/build-support/fetchhg/nix-prefetch-hg b/pkgs/build-support/fetchhg/nix-prefetch-hg
index 075dbc9c367..7d4c0c8d741 100755
--- a/pkgs/build-support/fetchhg/nix-prefetch-hg
+++ b/pkgs/build-support/fetchhg/nix-prefetch-hg
@@ -35,11 +35,10 @@ fi
 # download the file and add it to the store.
 if test -z "$finalPath"; then
 
-    tmpPath=/tmp/hg-checkout-tmp-$$
-    tmpArchive=$tmpPath/hg-archive
-    mkdir $tmpPath
+    tmpPath="$(mktemp --tmpdir -d hg-checkout-tmp-XXXXXXXX)"
+    trap "rm -rf \"$tmpPath\"" EXIT
 
-    trap "rm -rf $tmpPath" EXIT
+    tmpArchive="$tmpPath/hg-archive"
 
     # Perform the checkout.
     if [[ $url != /* ]]; then