about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--perl/lib/Nix/Utils.pm11
-rw-r--r--scripts/download-from-binary-cache.pl.in5
2 files changed, 13 insertions, 3 deletions
diff --git a/perl/lib/Nix/Utils.pm b/perl/lib/Nix/Utils.pm
index 943b8dd4abfa..1e7e0b5afb2f 100644
--- a/perl/lib/Nix/Utils.pm
+++ b/perl/lib/Nix/Utils.pm
@@ -6,3 +6,14 @@ sub checkURL {
     my ($url) = @_;
     die "invalid URL ‘$url’\n" unless $url =~ /^ $urlRE $ /x;
 }
+
+sub uniq {
+    my %seen;
+    my @res;
+    foreach my $name (@_) {
+        next if $seen{$name};
+        $seen{$name} = 1;
+        push @res, $name;
+    }
+    return @res;
+}
diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in
index 76306405cc05..e65e2d5b36d2 100644
--- a/scripts/download-from-binary-cache.pl.in
+++ b/scripts/download-from-binary-cache.pl.in
@@ -8,7 +8,6 @@ use Nix::Store;
 use Nix::Utils;
 use WWW::Curl::Easy;
 use WWW::Curl::Multi;
-use List::MoreUtils qw(any uniq);
 use strict;
 
 
@@ -195,12 +194,12 @@ sub getAvailableCaches {
         @urls = ();
         foreach my $url (@untrustedUrls) {
             die "binary cache ‘$url’ is not trusted (please add it to ‘trusted-binary-caches’ in $Nix::Config::confDir/nix.conf)\n"
-                unless any { $url eq $_ } @trustedUrls;
+                unless grep { $url eq $_ } @trustedUrls > 0;
             push @urls, $url;
         }
     }
 
-    foreach my $url (uniq @urls) {
+    foreach my $url (Nix::Utils::uniq @urls) {
 
         # FIXME: not atomic.
         $queryCache->execute($url);