1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

* Substitute fixes.

This commit is contained in:
Eelco Dolstra 2003-07-16 20:00:51 +00:00
parent b9ecadee6e
commit 9d56ca219f
8 changed files with 86 additions and 36 deletions

View file

@ -38,7 +38,7 @@ while (<CONFFILE>) {
# Nix archive from the network.
my $fetch =
"App(IncludeFix(\"fetchurl/fetchurl.fix\"), " .
"[(\"url\", \"$url/$fn\"), (\"hash\", \"\")])";
"[(\"url\", \"$url/$fn\"), (\"md5\", \"ignore\")])";
my $fixexpr =
"App(IncludeFix(\"nar/unnar.fix\"), " .
"[ (\"nar\", $fetch)" .

View file

@ -2,14 +2,14 @@
my @pushlist;
foreach my $hash (@ARGV) {
foreach my $id (@ARGV) {
die unless $hash =~ /^([0-9a-z]{32})$/;
die unless $id =~ /^([0-9a-z]{32})$/;
# Get all paths referenced by the normalisation of the given
# fstate expression.
my @paths;
open PATHS, "nix -qrh $hash 2> /dev/null |" or die "nix -qrh";
open PATHS, "nix -qrh $id 2> /dev/null |" or die "nix -qrh";
while (<PATHS>) {
chomp;
next unless /^\//;
@ -21,15 +21,12 @@ foreach my $hash (@ARGV) {
# a Nix archive.
foreach my $path (@paths) {
# Hash the path.
my $phash = `nix-hash $path`;
$? and die "nix-hash";
chomp $phash;
die unless $phash =~ /^([0-9a-z]{32})$/;
next unless ($path =~ /\/([0-9a-z]{32})[^\/]*/);
my $pathid = $1;
# Construct a name for the Nix archive. If the file is an
# fstate successor, encode this into the name.
my $name = $phash;
my $name = $pathid;
if ($path =~ /-s-([0-9a-z]{32}).nix$/) {
$name = "$name-s-$1";
}
@ -38,7 +35,7 @@ foreach my $hash (@ARGV) {
# Construct a Fix expression that creates a Nix archive.
my $fixexpr =
"App(IncludeFix(\"nar/nar.fix\"), " .
"[ (\"path\", Path(\"$path\", Hash(\"$phash\"), [Include(\"$hash\")]))" .
"[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" .
", (\"name\", \"$name\")" .
"])";
@ -48,13 +45,13 @@ foreach my $hash (@ARGV) {
close FIX;
# Instantiate a Nix expression from the Fix expression.
my $nhash = `fix $fixfile`;
my $nid = `fix $fixfile`;
$? and die "instantiating Nix archive expression";
chomp $nhash;
die unless $nhash =~ /^([0-9a-z]{32})$/;
chomp $nid;
die unless $nid =~ /^([0-9a-z]{32})$/;
# Realise the Nix expression.
my $npath = `nix -qph $nhash 2> /dev/null`;
my $npath = `nix -qph $nid 2> /dev/null`;
$? and die "creating Nix archive";
chomp $npath;