summary refs log tree commit diff
path: root/scripts/nix-channel.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-09-17 16:08:24 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-09-17 16:08:24 +0000
commit055608227f5a003825a905b0eb2aea39cba5ca16 (patch)
treefd3f4a9e9e6dd0df64e208b74f84ac7d79a67808 /scripts/nix-channel.in
parent3339f854473863c8780e537626f457be0b2b33e2 (diff)
downloadguix-055608227f5a003825a905b0eb2aea39cba5ca16.tar.gz
* nix-env: allow ~/.nix-defexpr to be a directory. If it is, then the
  Nix expressions in that directory are combined into an attribute set
  {file1 = import file1; file2 = import file2; ...}, i.e. each Nix
  expression is an attribute with the file name as the attribute
  name.  Also recurses into directories.

* nix-env: removed the "--import" (-I) option which set the
  ~/.nix-defexpr symlink.

* nix-channel: don't use "nix-env --import", instead symlink
  ~/.nix-defexpr/channels.  So finally nix-channel --update doesn't
  override any default Nix expressions but combines with them.

  This means that you can have (say) a local Nixpkgs SVN tree and use
  it as a default for nix-env:

  $ ln -s .../path-to-nixpkgs-tree ~/.nix-defexpr/nixpkgs_svn

  and be subscribed to channels (including Nixpkgs) at the same time.
  (If there is any ambiguity, the -A flag can be used to
  disambiguate, e.g. "nix-env -i -A nixpkgs_svn.pan".)

Diffstat (limited to 'scripts/nix-channel.in')
-rw-r--r--scripts/nix-channel.in11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index 1efb1a03a1..c023a75398 100644
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -18,6 +18,8 @@ $ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache if -W $channelCache;
 my $home = $ENV{"HOME"};
 die '$HOME not set' unless defined $home;
 my $channelsList = "$home/.nix-channels";
+
+my $nixDefExpr = "$home/.nix-defexpr";
     
 
 my @channels;
@@ -136,9 +138,12 @@ sub update {
 
     unlink "$rootFile.tmp";
 
-    # Make it the default Nix expression for `nix-env'.
-    system("@bindir@/nix-env", "--import", "$outPath") == 0
-         or die "cannot pull set default Nix expression to `$outPath'";
+    # Make the channels appear in nix-env.
+    unlink $nixDefExpr if -l $nixDefExpr; # old-skool ~/.nix-defexpr
+    mkdir $nixDefExpr or die "cannot create directory `$nixDefExpr'" if !-e $nixDefExpr;
+    my $channelLink = "$nixDefExpr/channels";
+    unlink $channelLink; # !!! not atomic
+    symlink($outPath, $channelLink) or die "cannot symlink `$channelLink' to `$outPath'";
 }