forked from lix-project/lix
* Fix nix-push.
This commit is contained in:
parent
ab0bc4999a
commit
9486dda115
|
@ -1,12 +1,13 @@
|
||||||
all-local: nar.sh unnar.sh
|
all-local: nar.sh unnar.sh
|
||||||
|
|
||||||
install-exec-local:
|
install-exec-local:
|
||||||
$(INSTALL) -d $(datadir)/fix/nar
|
$(INSTALL) -d $(datadir)/nix/corepkgs
|
||||||
$(INSTALL_DATA) nar.fix $(datadir)/fix/nar
|
$(INSTALL) -d $(datadir)/nix/corepkgs/nar
|
||||||
$(INSTALL_PROGRAM) nar.sh $(datadir)/fix/nar
|
$(INSTALL_DATA) nar.nix $(datadir)/nix/corepkgs/nar
|
||||||
$(INSTALL_DATA) unnar.fix $(datadir)/fix/nar
|
$(INSTALL_PROGRAM) nar.sh $(datadir)/nix/corepkgs/nar
|
||||||
$(INSTALL_PROGRAM) unnar.sh $(datadir)/fix/nar
|
$(INSTALL_DATA) unnar.nix $(datadir)/nix/corepkgs/nar
|
||||||
|
$(INSTALL_PROGRAM) unnar.sh $(datadir)/nix/corepkgs/nar
|
||||||
|
|
||||||
include ../../substitute.mk
|
include ../../substitute.mk
|
||||||
|
|
||||||
EXTRA_DIST = nar.fix nar.sh.in unnar.fix unnar.sh.in
|
EXTRA_DIST = nar.nix nar.sh.in unnar.nix unnar.sh.in
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
Function(["path"],
|
|
||||||
Package(
|
|
||||||
[ ("name", "nar")
|
|
||||||
, ("build", Relative("nar/nar.sh"))
|
|
||||||
, ("path", Var("path"))
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
6
corepkgs/nar/nar.nix
Normal file
6
corepkgs/nar/nar.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{system, path}: derivation {
|
||||||
|
name = "nar";
|
||||||
|
builder = ./nar.sh;
|
||||||
|
system = system;
|
||||||
|
path = path;
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ export PATH=/bin:/usr/bin
|
||||||
echo "packing $path into $out..."
|
echo "packing $path into $out..."
|
||||||
mkdir $out || exit 1
|
mkdir $out || exit 1
|
||||||
dst=$out/`basename $path`.nar.bz2
|
dst=$out/`basename $path`.nar.bz2
|
||||||
@bindir@/nix --dump "$path" | bzip2 > $dst || exit 1
|
@bindir@/nix-store --dump "$path" | bzip2 > $dst || exit 1
|
||||||
|
|
||||||
md5=$(md5sum -b $dst | cut -c1-32)
|
md5=$(md5sum -b $dst | cut -c1-32)
|
||||||
if test $? != 0; then exit 1; fi
|
if test $? != 0; then exit 1; fi
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
Function(["nar", "outPath"],
|
|
||||||
Package(
|
|
||||||
[ ("name", "unnar")
|
|
||||||
, ("outPath", Var("outPath"))
|
|
||||||
, ("build", Relative("nar/unnar.sh"))
|
|
||||||
, ("nar", Var("nar"))
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
7
corepkgs/nar/unnar.nix
Normal file
7
corepkgs/nar/unnar.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{system, narFile, outPath}: derivation {
|
||||||
|
name = "unnar";
|
||||||
|
builder = ./unnar.sh;
|
||||||
|
system = system;
|
||||||
|
narFile = narFile;
|
||||||
|
outPath = outPath;
|
||||||
|
}
|
|
@ -3,4 +3,4 @@
|
||||||
export PATH=/bin:/usr/bin
|
export PATH=/bin:/usr/bin
|
||||||
|
|
||||||
echo "unpacking $nar to $out..."
|
echo "unpacking $nar to $out..."
|
||||||
bunzip2 < $nar | @bindir@/nix --restore "$out" || exit 1
|
bunzip2 < $nar | @bindir@/nix-store --restore "$out" || exit 1
|
||||||
|
|
|
@ -7,14 +7,13 @@ my $tmpdir;
|
||||||
do { $tmpdir = tmpnam(); }
|
do { $tmpdir = tmpnam(); }
|
||||||
until mkdir $tmpdir, 0777;
|
until mkdir $tmpdir, 0777;
|
||||||
|
|
||||||
my $fixfile = "$tmpdir/create-nars.fix";
|
my $nixfile = "$tmpdir/create-nars.nix";
|
||||||
my $manifest = "$tmpdir/MANIFEST";
|
my $manifest = "$tmpdir/MANIFEST";
|
||||||
|
|
||||||
END { unlink $manifest; unlink $fixfile; rmdir $tmpdir; }
|
END { unlink $manifest; unlink $fixfile; rmdir $tmpdir; }
|
||||||
|
|
||||||
open FIX, ">$fixfile";
|
open NIX, ">$nixfile";
|
||||||
print FIX "[";
|
print NIX "[";
|
||||||
my $first = 1;
|
|
||||||
|
|
||||||
my @paths;
|
my @paths;
|
||||||
|
|
||||||
|
@ -24,10 +23,10 @@ foreach my $id (@ARGV) {
|
||||||
|
|
||||||
# Get all paths referenced by the normalisation of the given
|
# Get all paths referenced by the normalisation of the given
|
||||||
# Nix expression.
|
# Nix expression.
|
||||||
system "nix --install $id > /dev/null";
|
system "nix-store --realise $id > /dev/null";
|
||||||
if ($?) { die "`nix --install' failed"; }
|
die if ($?);
|
||||||
|
|
||||||
open PATHS, "nix --query --requisites --include-successors $id 2> /dev/null |" or die "nix -qr";
|
open PATHS, "nix-store --query --requisites --include-successors $id 2> /dev/null |" or die;
|
||||||
while (<PATHS>) {
|
while (<PATHS>) {
|
||||||
chomp;
|
chomp;
|
||||||
die "bad: $_" unless /^\//;
|
die "bad: $_" unless /^\//;
|
||||||
|
@ -35,34 +34,31 @@ foreach my $id (@ARGV) {
|
||||||
}
|
}
|
||||||
close PATHS;
|
close PATHS;
|
||||||
|
|
||||||
# For each path, create a Fix expression that turns the path into
|
# For each path, create a Nix expression that turns the path into
|
||||||
# a Nix archive.
|
# a Nix archive.
|
||||||
foreach my $path (@paths) {
|
foreach my $path (@paths) {
|
||||||
|
|
||||||
die unless ($path =~ /\/[0-9a-z]{32}.*$/);
|
die unless ($path =~ /\/[0-9a-z]{32}.*$/);
|
||||||
print "$path\n";
|
print "$path\n";
|
||||||
|
|
||||||
# Construct a Fix expression that creates a Nix archive.
|
|
||||||
my $fixexpr =
|
|
||||||
"Call(IncludeFix(\"nar/nar.fix\"), " .
|
|
||||||
"[ (\"path\", Closure([\"$path\"], [(\"$path\", [])]))" .
|
|
||||||
"])";
|
|
||||||
|
|
||||||
print FIX "," unless ($first);
|
|
||||||
$first = 0;
|
|
||||||
print FIX $fixexpr;
|
|
||||||
|
|
||||||
|
# Construct a Nix expression that creates a Nix archive.
|
||||||
|
my $nixexpr =
|
||||||
|
"((import @datadir@/nix/corepkgs/nar/nar.nix) " .
|
||||||
|
# !!! $path should be represented as a closure
|
||||||
|
"{path = \"$path\"; system = \"@host@\"}) ";
|
||||||
|
|
||||||
|
print NIX $nixexpr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print FIX "]";
|
print NIX "]";
|
||||||
close FIX;
|
close NIX;
|
||||||
|
|
||||||
|
|
||||||
# Instantiate a Nix expression from the Fix expression.
|
# Instantiate a store expression from the Nix expression.
|
||||||
my @nids;
|
my @nids;
|
||||||
print STDERR "running fix...\n";
|
print STDERR "instantiating Nix expression...\n";
|
||||||
open NIDS, "fix $fixfile |" or die "cannot run fix";
|
open NIDS, "nix-instantiate $nixfile |" or die "cannot run nix-instantiate";
|
||||||
while (<NIDS>) {
|
while (<NIDS>) {
|
||||||
chomp;
|
chomp;
|
||||||
die unless /^\//;
|
die unless /^\//;
|
||||||
|
@ -71,13 +67,13 @@ while (<NIDS>) {
|
||||||
close NIDS;
|
close NIDS;
|
||||||
|
|
||||||
|
|
||||||
# Realise the Nix expression.
|
# Realise the store expression.
|
||||||
print STDERR "creating archives...\n";
|
print STDERR "creating archives...\n";
|
||||||
system "nix --install -v @nids > /dev/null";
|
system "nix-store --realise -v @nids > /dev/null";
|
||||||
if ($?) { die "`nix --install' failed"; }
|
if ($?) { die "`nix --realise' failed"; }
|
||||||
|
|
||||||
my @narpaths;
|
my @narpaths;
|
||||||
open NIDS, "nix --query --list @nids |" or die "cannot run nix";
|
open NIDS, "nix-store --query --list @nids |" or die "cannot run nix";
|
||||||
while (<NIDS>) {
|
while (<NIDS>) {
|
||||||
chomp;
|
chomp;
|
||||||
die unless (/^\//);
|
die unless (/^\//);
|
||||||
|
@ -120,13 +116,13 @@ for (my $n = 0; $n < scalar @paths; $n++) {
|
||||||
print MANIFEST " MD5: $hash\n";
|
print MANIFEST " MD5: $hash\n";
|
||||||
|
|
||||||
if ($storepath =~ /\.nix$/) {
|
if ($storepath =~ /\.nix$/) {
|
||||||
open PREDS, "nix --query --predecessors $storepath |" or die "cannot run nix";
|
open PREDS, "nix-store --query --predecessors $storepath |" or die "cannot run nix";
|
||||||
while (<PREDS>) {
|
while (<PREDS>) {
|
||||||
chomp;
|
chomp;
|
||||||
die unless (/^\//);
|
die unless (/^\//);
|
||||||
print MANIFEST " SuccOf: $_\n";
|
print MANIFEST " SuccOf: $_\n";
|
||||||
}
|
}
|
||||||
close PREDS;
|
close PREDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
print MANIFEST "}\n";
|
print MANIFEST "}\n";
|
||||||
|
|
|
@ -53,8 +53,8 @@ static void printNixExpr(EvalState & state, Expr e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ATgetType(e) == AT_LIST) {
|
if (atMatch(m, e) >> "List" >> es) {
|
||||||
for (ATermIterator i((ATermList) e); i; ++i)
|
for (ATermIterator i(es); i; ++i)
|
||||||
printNixExpr(state, evalExpr(state, *i));
|
printNixExpr(state, evalExpr(state, *i));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue