* Generate the scripts so that we can substitute the prefix

etc. correctly.
* Fixed nix-switch.
This commit is contained in:
Eelco Dolstra 2003-07-13 18:58:03 +00:00
parent 5304a1eb3a
commit 9c620e4afa
6 changed files with 23 additions and 24 deletions

View file

@ -1,9 +1,19 @@
bin_SCRIPTS = nix-switch nix-collect-garbage \ bin_SCRIPTS = nix-switch nix-collect-garbage \
nix-pull nix-push nix-pull nix-push
noinst_SCRIPTS = nix-profile.sh
install-exec-local: install-exec-local:
$(INSTALL) -d $(sysconfdir)/profile.d $(INSTALL) -d $(sysconfdir)/profile.d
$(INSTALL_PROGRAM) nix-profile.sh $(sysconfdir)/profile.d/nix.sh $(INSTALL_PROGRAM) nix-profile.sh $(sysconfdir)/profile.d/nix.sh
$(INSTALL) -d $(sysconfdir)/nix $(INSTALL) -d $(sysconfdir)/nix
# !!! don't overwrite local modifications # !!! don't overwrite local modifications
$(INSTALL_DATA) prebuilts.conf $(sysconfdir)/nix/prebuilts.conf $(INSTALL_DATA) prebuilts.conf $(sysconfdir)/nix/prebuilts.conf
%: %.in Makefile
sed \
-e s^@prefix\@^$(prefix)^g \
-e s^@sysconfdir\@^$(sysconfdir)^g \
-e s^@localstatedir\@^$(localstatedir)^g \
< $< > $@ || rm $@
chmod +x $@

View file

@ -1,10 +1,10 @@
if test -z "$NIX_SET"; then #if test -z "$NIX_SET"; then
export NIX_SET=1 # export NIX_SET=1
NIX_LINKS=/nix/var/nix/links/current NIX_LINKS=@localstatedir@/nix/links/current
export PATH=$NIX_LINKS/bin:/nix/bin:$PATH export PATH=$NIX_LINKS/bin:@prefix@/bin:$PATH
export LD_LIBRARY_PATH=$NIX_LINKS/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$NIX_LINKS/lib:$LD_LIBRARY_PATH
@ -17,4 +17,4 @@ if test -z "$NIX_SET"; then
# export MANPATH=$NIX_LINKS/man:$MANPATH # export MANPATH=$NIX_LINKS/man:$MANPATH
fi #fi

View file

@ -1,10 +1,7 @@
#! /usr/bin/perl -w #! /usr/bin/perl -w
my $prefix = $ENV{"NIX"} || "/tmp/nix"; # !!! use prefix my $tmpfile = "@localstatedir@/nix/pull.tmp";
my $etcdir = "$prefix/etc/nix"; my $conffile = "@sysconfdir@/nix/prebuilts.conf";
my $tmpfile = "$prefix/var/nix/pull.tmp";
my $conffile = "$etcdir/prebuilts.conf";
my @subs; my @subs;
my @sucs; my @sucs;

View file

@ -12,29 +12,24 @@ if (scalar @ARGV > 0 && $ARGV[0] eq "--keep") {
my $hash = $ARGV[0]; my $hash = $ARGV[0];
$hash || die "no package hash specified"; $hash || die "no package hash specified";
my $prefix = $ENV{"NIX"} || "/nix"; # !!! use prefix my $linkdir = "@localstatedir@/nix/links";
my $linkdir = "$prefix/var/nix/links";
# Build the specified package, and all its dependencies. # Build the specified package, and all its dependencies.
my $pkgdir = `nix getpkg $hash`; my $pkgdir = `nix -qph $hash`;
if ($?) { die "`nix getpkg' failed"; } if ($?) { die "`nix -qph' failed"; }
chomp $pkgdir; chomp $pkgdir;
my $id = `nix info $hash | cut -c 34-`;
if ($?) { die "`nix info' failed"; }
chomp $id;
# Figure out a generation number. # Figure out a generation number.
my $nr = 0; my $nr = 0;
while (-e "$linkdir/$id-$nr") { $nr++; } while (-e "$linkdir/$nr") { $nr++; }
my $link = "$linkdir/$id-$nr"; my $link = "$linkdir/$nr";
# Create a symlink from $link to $pkgdir. # Create a symlink from $link to $pkgdir.
symlink($pkgdir, $link) or die "cannot create $link: $!"; symlink($pkgdir, $link) or die "cannot create $link: $!";
# Also store the hash of $pkgdir. This is useful for garbage # Also store the hash of $pkgdir. This is useful for garbage
# collection and the like. # collection and the like.
my $hashfile = "$linkdir/$id-$nr.hash"; my $hashfile = "$linkdir/$nr.hash";
open HASH, "> $hashfile" or die "cannot create $hashfile"; open HASH, "> $hashfile" or die "cannot create $hashfile";
print HASH "$hash\n"; print HASH "$hash\n";
close HASH; close HASH;

View file

@ -25,9 +25,6 @@ libnix_a_SOURCES = util.cc hash.cc archive.cc md5.c \
install-data-local: install-data-local:
$(INSTALL) -d $(localstatedir)/nix $(INSTALL) -d $(localstatedir)/nix
$(INSTALL) -d $(localstatedir)/nix/links $(INSTALL) -d $(localstatedir)/nix/links
# $(INSTALL) -d $(localstatedir)/nix/prebuilts
# $(INSTALL) -d $(localstatedir)/nix/prebuilts/imports
# $(INSTALL) -d $(localstatedir)/nix/prebuilts/exports
$(INSTALL) -d $(localstatedir)/log/nix $(INSTALL) -d $(localstatedir)/log/nix
$(INSTALL) -d $(prefix)/store $(INSTALL) -d $(prefix)/store
$(bindir)/nix --init $(bindir)/nix --init