about summary refs log tree commit diff
path: root/pkgs/servers/x11
diff options
context:
space:
mode:
authorAndrew Childs <lorne@cons.org.nz>2018-08-20 23:11:28 +0900
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-10-11 13:41:27 -0400
commit0e12683470bc55da1f7739588a5ff7b236597d01 (patch)
tree3d00d761d76fb73ce64799b59e65dafa15139c22 /pkgs/servers/x11
parent9454f71fefcbe413fdfcb61b510256f1301c5f5c (diff)
downloadnixlib-0e12683470bc55da1f7739588a5ff7b236597d01.tar
nixlib-0e12683470bc55da1f7739588a5ff7b236597d01.tar.gz
nixlib-0e12683470bc55da1f7739588a5ff7b236597d01.tar.bz2
nixlib-0e12683470bc55da1f7739588a5ff7b236597d01.tar.lz
nixlib-0e12683470bc55da1f7739588a5ff7b236597d01.tar.xz
nixlib-0e12683470bc55da1f7739588a5ff7b236597d01.tar.zst
nixlib-0e12683470bc55da1f7739588a5ff7b236597d01.zip
xorg: add caching to generate-expr-from-tarballs.pl
Diffstat (limited to 'pkgs/servers/x11')
-rwxr-xr-xpkgs/servers/x11/xorg/generate-expr-from-tarballs.pl16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl b/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl
index 8e8f97546375..c919a548480a 100755
--- a/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl
+++ b/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl
@@ -13,6 +13,9 @@
 use strict;
 use warnings;
 
+use File::Basename;
+use File::Spec::Functions;
+
 my $tmpDir = "/tmp/xorg-unpack";
 
 
@@ -43,7 +46,6 @@ $pcMap{"\$DRI2PROTO"} = "dri2proto";
 
 
 my $downloadCache = "./download-cache";
-$ENV{'NIX_DOWNLOAD_CACHE'} = $downloadCache;
 mkdir $downloadCache, 0755;
 
 
@@ -76,7 +78,17 @@ while (<>) {
     $pkgURLs{$pkg} = $tarball;
     $pkgNames{$pkg} = $pkgName;
 
-    my ($hash, $path) = `PRINT_PATH=1 QUIET=1 nix-prefetch-url '$tarball'`;
+    my $cachePath = catdir($downloadCache, basename($tarball));
+    my $hash;
+    my $path;
+    if (-e $cachePath) {
+        $path = readlink($cachePath);
+        $hash = `nix-hash --type sha256 --base32 --flat $cachePath`;
+    }
+    else {
+        ($hash, $path) = `PRINT_PATH=1 QUIET=1 nix-prefetch-url '$tarball'`;
+        `nix-store --realise --add-root $cachePath --indirect $path`;
+    }
     chomp $hash;
     chomp $path;
     $pkgHashes{$pkg} = $hash;