about summary refs log tree commit diff
path: root/scripts/nix-unpack-closure.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/nix-unpack-closure.in')
-rw-r--r--scripts/nix-unpack-closure.in8
1 files changed, 3 insertions, 5 deletions
diff --git a/scripts/nix-unpack-closure.in b/scripts/nix-unpack-closure.in
index 20fdef7594d2..89e7aa24d5cb 100644
--- a/scripts/nix-unpack-closure.in
+++ b/scripts/nix-unpack-closure.in
@@ -7,15 +7,13 @@
 # directory.
 
 use strict;
-use POSIX qw(tmpnam);
+use File::Temp qw(tempdir);
 
 my $binDir = $ENV{"NIX_BIN_DIR"};
 $binDir = "@bindir@" unless defined $binDir;
 
-my $tmpDir;
-do { $tmpDir = tmpnam(); }
-until mkdir $tmpDir, 0777;
-END { my $x = $?; system("@coreutils@/rm", "-rf", $tmpDir); $? = $x; }
+my $tmpDir = tempdir("nix-unpack-closure.XXXXXX", CLEANUP => 1, TMPDIR => 1)
+    or die "cannot create a temporary directory";
 
 
 # Unpack the NAR archive on standard input.