about summary refs log tree commit diff
path: root/scripts/nix-push.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/nix-push.in')
-rw-r--r--scripts/nix-push.in17
1 files changed, 7 insertions, 10 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index 02b1dec482a3..e5bd404a2d8a 100644
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -1,19 +1,16 @@
 #! @perl@ -w -I@libexecdir@/nix
 
 use strict;
-use POSIX qw(tmpnam);
+use File::Temp qw(tempdir);
 use readmanifest;
 
 my $hashAlgo = "sha256";
 
-my $tmpdir;
-do { $tmpdir = tmpnam(); }
-until mkdir $tmpdir, 0777;
+my $tmpDir = tempdir("nix-push.XXXXXX", CLEANUP => 1, TMPDIR => 1)
+    or die "cannot create a temporary directory";
 
-my $nixfile = "$tmpdir/create-nars.nix";
-my $manifest = "$tmpdir/MANIFEST";
-
-END { unlink $manifest; unlink $nixfile; rmdir $tmpdir; }
+my $nixExpr = "$tmpDir/create-nars.nix";
+my $manifest = "$tmpDir/MANIFEST";
 
 my $curl = "@curl@ --fail --silent";
 my $extraCurlFlags = ${ENV{'CURL_FLAGS'}};
@@ -101,7 +98,7 @@ my @storePaths = keys %storePaths;
 
 # For each path, create a Nix expression that turns the path into
 # a Nix archive.
-open NIX, ">$nixfile";
+open NIX, ">$nixExpr";
 print NIX "[";
 
 foreach my $storePath (@storePaths) {
@@ -122,7 +119,7 @@ close NIX;
 # Instantiate store expressions from the Nix expression.
 my @storeExprs;
 print STDERR "instantiating store expressions...\n";
-my $pid = open(READ, "$binDir/nix-instantiate $nixfile|")
+my $pid = open(READ, "$binDir/nix-instantiate $nixExpr|")
     or die "cannot run nix-instantiate";
 while (<READ>) {
     chomp;