mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
* nix-channel: supports users who don't have write permission to the
manifests directory. In that case, we don't do a nix-pull, so the user gets pure source deployment. The directory /nix/var/nix/gcroots/per-user/$USER should be writable. (It's created automatically if /nix/var/nix/gcroots/per-user is writable, e.g. if it has 1777 permission.)
This commit is contained in:
parent
2629998e91
commit
7d5836b34d
1 changed files with 21 additions and 12 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
my $rootsDir = "@localstatedir@/nix/gcroots/channels";
|
my $rootsDir = "@localstatedir@/nix/gcroots";
|
||||||
|
|
||||||
my $stateDir = $ENV{"NIX_STATE_DIR"};
|
my $stateDir = $ENV{"NIX_STATE_DIR"};
|
||||||
$stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
$stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
||||||
|
@ -10,8 +10,8 @@ $stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
||||||
|
|
||||||
# Turn on caching in nix-prefetch-url.
|
# Turn on caching in nix-prefetch-url.
|
||||||
my $channelCache = "$stateDir/channel-cache";
|
my $channelCache = "$stateDir/channel-cache";
|
||||||
$ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache;
|
|
||||||
mkdir $channelCache, 0755 unless -e $channelCache;
|
mkdir $channelCache, 0755 unless -e $channelCache;
|
||||||
|
$ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache if -W $channelCache;
|
||||||
|
|
||||||
|
|
||||||
# Figure out the name of the `.nix-channels' file to use.
|
# Figure out the name of the `.nix-channels' file to use.
|
||||||
|
@ -76,16 +76,25 @@ sub removeChannel {
|
||||||
sub update {
|
sub update {
|
||||||
readChannels;
|
readChannels;
|
||||||
|
|
||||||
# Remove all the old manifests.
|
# Do we have write permission to the manifests directory? If not,
|
||||||
for my $manifest (glob "$stateDir/manifests/*.nixmanifest") {
|
# then just skip pulling the manifest and just download the Nix
|
||||||
unlink $manifest or die "cannot remove `$manifest': $!";
|
# expressions. If the user is a non-privileged user in a
|
||||||
}
|
# multi-user Nix installation, he at least gets installation from
|
||||||
|
# source.
|
||||||
|
if (-W "$stateDir/manifests") {
|
||||||
|
|
||||||
|
# Remove all the old manifests.
|
||||||
|
for my $manifest (glob "$stateDir/manifests/*.nixmanifest") {
|
||||||
|
unlink $manifest or die "cannot remove `$manifest': $!";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pull cache manifests.
|
||||||
|
foreach my $url (@channels) {
|
||||||
|
#print "pulling cache manifest from `$url'\n";
|
||||||
|
system("@bindir@/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
|
||||||
|
or die "cannot pull cache manifest from `$url'";
|
||||||
|
}
|
||||||
|
|
||||||
# Pull cache manifests.
|
|
||||||
foreach my $url (@channels) {
|
|
||||||
#print "pulling cache manifest from `$url'\n";
|
|
||||||
system("@bindir@/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
|
|
||||||
or die "cannot pull cache manifest from `$url'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a Nix expression that fetches and unpacks the channel Nix
|
# Create a Nix expression that fetches and unpacks the channel Nix
|
||||||
|
@ -112,7 +121,7 @@ sub update {
|
||||||
my $userName = getpwuid($<);
|
my $userName = getpwuid($<);
|
||||||
die "who ARE you? go away" unless defined $userName;
|
die "who ARE you? go away" unless defined $userName;
|
||||||
|
|
||||||
my $rootFile = "$rootsDir/$userName";
|
my $rootFile = "$rootsDir/per-user/$userName/channels";
|
||||||
|
|
||||||
# Instantiate the Nix expression.
|
# Instantiate the Nix expression.
|
||||||
print "unpacking channel Nix expressions...\n";
|
print "unpacking channel Nix expressions...\n";
|
||||||
|
|
Loading…
Reference in a new issue