mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
* Place manifests in /nix/var/nix/manifests.
* Use the new patch downloader.
This commit is contained in:
parent
7eed57e784
commit
3d1b2101cc
12 changed files with 35 additions and 79 deletions
|
@ -195,7 +195,6 @@ AC_CONFIG_FILES([Makefile
|
||||||
corepkgs/nar/Makefile
|
corepkgs/nar/Makefile
|
||||||
corepkgs/buildenv/Makefile
|
corepkgs/buildenv/Makefile
|
||||||
corepkgs/channels/Makefile
|
corepkgs/channels/Makefile
|
||||||
corepkgs/nix-pull/Makefile
|
|
||||||
doc/Makefile
|
doc/Makefile
|
||||||
doc/manual/Makefile
|
doc/manual/Makefile
|
||||||
misc/Makefile
|
misc/Makefile
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
SUBDIRS = fetchurl nar buildenv channels nix-pull
|
SUBDIRS = fetchurl nar buildenv channels
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
all-local: builder.sh
|
|
||||||
|
|
||||||
install-exec-local:
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
|
|
||||||
$(INSTALL_DATA) default.nix $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
|
|
||||||
$(INSTALL_PROGRAM) builder.sh $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
|
|
||||||
|
|
||||||
include ../../substitute.mk
|
|
||||||
|
|
||||||
EXTRA_DIST = default.nix builder.sh.in
|
|
|
@ -1,34 +0,0 @@
|
||||||
#! @shell@ -e
|
|
||||||
|
|
||||||
export PATH=/bin:/usr/bin
|
|
||||||
|
|
||||||
mkdir $out
|
|
||||||
|
|
||||||
cat > $out/fetch <<EOF
|
|
||||||
#! @shell@ -e
|
|
||||||
|
|
||||||
export PATH=/bin:/usr/bin
|
|
||||||
|
|
||||||
echo "downloading \$2..."
|
|
||||||
|
|
||||||
export PRINT_PATH=1
|
|
||||||
result=(\$(@bindir@/nix-prefetch-url \$2))
|
|
||||||
|
|
||||||
hash=\${result[0]}
|
|
||||||
path=\${result[1]}
|
|
||||||
|
|
||||||
if test "\$hash" != "\$3"; then
|
|
||||||
echo "hash is \$hash, expected \$3"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "unpacking into \$1..."
|
|
||||||
|
|
||||||
if ! @bunzip2@ < "\$path" | @bindir@/nix-store --restore "\$1"; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x $out/fetch
|
|
|
@ -1,7 +0,0 @@
|
||||||
{system}:
|
|
||||||
|
|
||||||
derivation {
|
|
||||||
name = "nix-pull";
|
|
||||||
builder = ./builder.sh;
|
|
||||||
inherit system;
|
|
||||||
}
|
|
|
@ -4,13 +4,14 @@ bin_SCRIPTS = nix-collect-garbage \
|
||||||
|
|
||||||
noinst_SCRIPTS = nix-profile.sh
|
noinst_SCRIPTS = nix-profile.sh
|
||||||
|
|
||||||
nix-pull nix-push: readmanifest.pm
|
nix-pull nix-push: readmanifest.pm download-using-manifests.pl
|
||||||
|
|
||||||
install-exec-local: readmanifest.pm
|
install-exec-local: readmanifest.pm download-using-manifests.pl
|
||||||
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d
|
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d
|
||||||
$(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh
|
$(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh
|
||||||
$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix
|
$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix
|
||||||
$(INSTALL_DATA) readmanifest.pm $(DESTDIR)$(libexecdir)/nix
|
$(INSTALL_DATA) readmanifest.pm $(DESTDIR)$(libexecdir)/nix
|
||||||
|
$(INSTALL_PROGRAM) download-using-manifests.pl $(DESTDIR)$(libexecdir)/nix
|
||||||
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
|
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
|
||||||
|
|
||||||
include ../substitute.mk
|
include ../substitute.mk
|
||||||
|
@ -20,4 +21,5 @@ EXTRA_DIST = nix-collect-garbage.in \
|
||||||
nix-prefetch-url.in nix-install-package.in \
|
nix-prefetch-url.in nix-install-package.in \
|
||||||
nix-channel.in \
|
nix-channel.in \
|
||||||
readmanifest.pm.in \
|
readmanifest.pm.in \
|
||||||
nix-build.in
|
nix-build.in \
|
||||||
|
download-using-manifests.pl.in
|
||||||
|
|
4
corepkgs/nix-pull/download.pl → scripts/download-using-manifests.pl.in
Executable file → Normal file
4
corepkgs/nix-pull/download.pl → scripts/download-using-manifests.pl.in
Executable file → Normal file
|
@ -1,9 +1,9 @@
|
||||||
#! /usr/bin/perl -w -I/home/eelco/Dev/nix/scripts
|
#! @perl@ -w -I@libexecdir@/nix
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use readmanifest;
|
use readmanifest;
|
||||||
|
|
||||||
my $manifestDir = "/home/eelco/Dev/nix/patch/test";
|
my $manifestDir = "@localstatedir@/nix/manifests";
|
||||||
|
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
0
scripts/nix-build.in
Executable file → Normal file
0
scripts/nix-build.in
Executable file → Normal file
0
scripts/nix-channel.in
Executable file → Normal file
0
scripts/nix-channel.in
Executable file → Normal file
0
scripts/nix-collect-garbage.in
Executable file → Normal file
0
scripts/nix-collect-garbage.in
Executable file → Normal file
|
@ -11,7 +11,7 @@ until mkdir $tmpdir, 0777;
|
||||||
|
|
||||||
my $manifest = "$tmpdir/manifest";
|
my $manifest = "$tmpdir/manifest";
|
||||||
|
|
||||||
#END { unlink $manifest; rmdir $tmpdir; }
|
END { unlink $manifest; rmdir $tmpdir; }
|
||||||
|
|
||||||
|
|
||||||
# Obtain URLs either from the command line or from a configuration file.
|
# Obtain URLs either from the command line or from a configuration file.
|
||||||
|
@ -28,8 +28,22 @@ sub processURL {
|
||||||
system("@curl@ --fail --silent --show-error --location --max-redirs 20 " .
|
system("@curl@ --fail --silent --show-error --location --max-redirs 20 " .
|
||||||
"'$url' > '$manifest'") == 0
|
"'$url' > '$manifest'") == 0
|
||||||
or die "curl failed: $?";
|
or die "curl failed: $?";
|
||||||
|
|
||||||
readManifest $manifest, \%narFiles, \%patches, \%successors;
|
readManifest $manifest, \%narFiles, \%patches, \%successors;
|
||||||
|
|
||||||
|
my $baseName = "unnamed";
|
||||||
|
if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component
|
||||||
|
$baseName = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $hash = `@bindir@/nix-hash --flat '$manifest'`
|
||||||
|
or die "cannot hash `$manifest'";
|
||||||
|
chomp $hash;
|
||||||
|
|
||||||
|
my $finalPath = "@localstatedir@/nix/manifests/$baseName-$hash.nixmanifest";
|
||||||
|
|
||||||
|
system("mv '$manifest' '$finalPath'") == 0
|
||||||
|
or die "cannot move `$manifest' to `$finalPath";
|
||||||
}
|
}
|
||||||
|
|
||||||
while (@ARGV) {
|
while (@ARGV) {
|
||||||
|
@ -42,18 +56,6 @@ my $size = scalar (keys %narFiles);
|
||||||
print "$size store paths in manifest\n";
|
print "$size store paths in manifest\n";
|
||||||
|
|
||||||
|
|
||||||
# Instantiate a store expression that builds the substitute program
|
|
||||||
# (the program that fetches URLs and unpacks them into the store).
|
|
||||||
my $nixExpr =
|
|
||||||
"(import @datadir@/nix/corepkgs/nix-pull) " .
|
|
||||||
"{system = \"@system@\";}";
|
|
||||||
|
|
||||||
print STDERR "building downloader...\n";
|
|
||||||
my $substProgram = `echo '$nixExpr' | @bindir@/nix-store -qnf \$(@bindir@/nix-instantiate -)`
|
|
||||||
or die "cannot instantiate Nix expression";
|
|
||||||
chomp $substProgram;
|
|
||||||
|
|
||||||
|
|
||||||
# Register all substitutes.
|
# Register all substitutes.
|
||||||
print STDERR "registering substitutes...\n";
|
print STDERR "registering substitutes...\n";
|
||||||
|
|
||||||
|
@ -66,10 +68,8 @@ foreach my $storePath (keys %narFiles) {
|
||||||
my $narFileList = $narFiles{$storePath};
|
my $narFileList = $narFiles{$storePath};
|
||||||
foreach my $narFile (@{$narFileList}) {
|
foreach my $narFile (@{$narFileList}) {
|
||||||
print WRITE "$storePath\n";
|
print WRITE "$storePath\n";
|
||||||
print WRITE "$substProgram/fetch\n";
|
print WRITE "@libexecdir@/nix/download-using-manifests.pl\n";
|
||||||
print WRITE "2\n";
|
print WRITE "0\n";
|
||||||
print WRITE "$narFile->{url}\n";
|
|
||||||
print WRITE "$narFile->{hash}\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ sub readManifest {
|
||||||
my $basePath;
|
my $basePath;
|
||||||
my $baseHash;
|
my $baseHash;
|
||||||
my $patchType;
|
my $patchType;
|
||||||
|
my $narHash;
|
||||||
|
|
||||||
while (<MANIFEST>) {
|
while (<MANIFEST>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
@ -34,6 +35,7 @@ sub readManifest {
|
||||||
undef $hash;
|
undef $hash;
|
||||||
$size = 999999999;
|
$size = 999999999;
|
||||||
@preds = ();
|
@preds = ();
|
||||||
|
undef $narHash;
|
||||||
}
|
}
|
||||||
elsif (/^patch \{$/) {
|
elsif (/^patch \{$/) {
|
||||||
$type = "patch";
|
$type = "patch";
|
||||||
|
@ -44,6 +46,7 @@ sub readManifest {
|
||||||
undef $basePath;
|
undef $basePath;
|
||||||
undef $baseHash;
|
undef $baseHash;
|
||||||
undef $patchType;
|
undef $patchType;
|
||||||
|
undef $narHash;
|
||||||
}
|
}
|
||||||
else { die "bad line: $_"; }
|
else { die "bad line: $_"; }
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,7 +74,9 @@ sub readManifest {
|
||||||
}
|
}
|
||||||
if (!$found) {
|
if (!$found) {
|
||||||
push @{$narFileList},
|
push @{$narFileList},
|
||||||
{url => $url, hash => $hash, size => $size};
|
{ url => $url, hash => $hash, size => $size
|
||||||
|
, narHash => $narHash
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $p (@preds) {
|
foreach my $p (@preds) {
|
||||||
|
@ -102,6 +107,7 @@ sub readManifest {
|
||||||
push @{$patchList},
|
push @{$patchList},
|
||||||
{ url => $url, hash => $hash, size => $size
|
{ url => $url, hash => $hash, size => $size
|
||||||
, basePath => $basePath, baseHash => $baseHash
|
, basePath => $basePath, baseHash => $baseHash
|
||||||
|
, narHash => $narHash
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,11 +123,12 @@ sub readManifest {
|
||||||
elsif (/^\s*BasePath:\s*(\/\S+)\s*$/) { $basePath = $1; }
|
elsif (/^\s*BasePath:\s*(\/\S+)\s*$/) { $basePath = $1; }
|
||||||
elsif (/^\s*BaseHash:\s*(\S+)\s*$/) { $baseHash = $1; }
|
elsif (/^\s*BaseHash:\s*(\S+)\s*$/) { $baseHash = $1; }
|
||||||
elsif (/^\s*Type:\s*(\S+)\s*$/) { $patchType = $1; }
|
elsif (/^\s*Type:\s*(\S+)\s*$/) { $patchType = $1; }
|
||||||
|
elsif (/^\s*NarHash:\s*(\S+)\s*$/) { $narHash = $1; }
|
||||||
|
|
||||||
# Compatibility;
|
# Compatibility;
|
||||||
elsif (/^\s*NarURL:\s*(\S+)\s*$/) { $url = $1; }
|
elsif (/^\s*NarURL:\s*(\S+)\s*$/) { $url = $1; }
|
||||||
elsif (/^\s*MD5:\s*(\S+)\s*$/) { $hash = $1; }
|
elsif (/^\s*MD5:\s*(\S+)\s*$/) { $hash = $1; }
|
||||||
|
|
||||||
else { die "bad line: $_"; }
|
else { die "bad line: $_"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue