about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-04-14T19·05+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-04-14T19·05+0200
commit0b5107c016080e70d30ccba3afa0f9aa7a90a891 (patch)
tree176724458a501591ae129aed133c95d2ecea1e71
parent1d0bafb74d17f14778005a633ee332ad0ad9ba9e (diff)
If the (redirected) channel URL contains a version number, use it
-rw-r--r--corepkgs/unpack-channel.nix4
-rw-r--r--corepkgs/unpack-channel.sh2
-rwxr-xr-xscripts/nix-channel.in8
3 files changed, 10 insertions, 4 deletions
diff --git a/corepkgs/unpack-channel.nix b/corepkgs/unpack-channel.nix
index eba957dff4e7..170f3ab07c77 100644
--- a/corepkgs/unpack-channel.nix
+++ b/corepkgs/unpack-channel.nix
@@ -1,11 +1,11 @@
 with import <nix/config.nix>;
 
-{ name, src }:
+{ name, channelName, src }:
 
 derivation {
   system = builtins.currentSystem;
   builder = shell;
   args = [ "-e" ./unpack-channel.sh ];
-  inherit name src bzip2 tar tr;
+  inherit name channelName src bzip2 tar tr;
   PATH = "${nixBinDir}:${coreutils}";
 }
diff --git a/corepkgs/unpack-channel.sh b/corepkgs/unpack-channel.sh
index 0b7d89bc4630..f42b0870ae18 100644
--- a/corepkgs/unpack-channel.sh
+++ b/corepkgs/unpack-channel.sh
@@ -1,4 +1,4 @@
 mkdir $out
 cd $out
 $bzip2 -d < $src | $tar xf -
-mv * $out/$name
+mv * $out/$channelName
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index b3251975b52b..64e5aa01282b 100755
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -108,7 +108,13 @@ sub update {
         die "cannot fetch `$fullURL'" if $? != 0;
         chomp $path;
 
-        $exprs .= "'f: f { name = \"$name\"; src = builtins.storePath \"$path\"; }' ";
+        # If the URL contains a version number, append it to the name
+        # attribute (so that "nix-env -q" on the channels profile
+        # shows something useful).
+        my $cname = $name;
+        $cname .= $1 if basename($url) =~ /(-\d.*)$/;
+
+        $exprs .= "'f: f { name = \"$cname\"; channelName = \"$name\"; src = builtins.storePath \"$path\"; }' ";
     }
 
     # Unpack the channel tarballs into the Nix store and install them