diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-04-01T14·00+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-04-01T14·00+0000 |
commit | 383f9bb0f19f76fa4cdbdfb5327d82e77212c1b6 (patch) | |
tree | 0a63999939d1a9cfc2143f08c68347f9ceb44b6b /src/nix-instantiate.in | |
parent | ced20f187e36927adc88ab628b67838f51155244 (diff) |
* Use ATerms for Nix descriptors.
Diffstat (limited to 'src/nix-instantiate.in')
-rwxr-xr-x | src/nix-instantiate.in | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/nix-instantiate.in b/src/nix-instantiate.in index 508b9eb28d07..b5093391b2d2 100755 --- a/src/nix-instantiate.in +++ b/src/nix-instantiate.in @@ -59,37 +59,57 @@ sub convert { my $OUT = new FileHandle; my $tmpfile = "$outdir/$fn-tmp"; open $IN, "< $descr" or die "cannot open $descr"; - open $OUT, "> $tmpfile" or die "cannot create $tmpfile"; - print $OUT "system : $system\n"; +# Descr([Bind("x", Str("y")), Bind("x", File("1234")), Bind("x", Pkg("1234"))]) +# bindings alphabetisch gesorteerd + + my %bindings; while (<$IN>) { chomp; + s/\s*#.*$//; + next if (/^$/); if (/^(\w+)\s*=\s*([^\#\s]*)\s*(\#.*)?$/) { my ($name, $loc) = ($1, $2); my $file = fetchFile($loc); $file = File::Spec->rel2abs($file, $dir); my $hash = hashFile($file); - print $OUT "$name = $hash\n"; + $bindings{$name} = "File(\"$hash\")"; } elsif (/^(\w+)\s*<-\s*([+\w\d\.\/-]+)\s*(\#.*)?$/) { my $name = $1; my $file = $2; $file = File::Spec->rel2abs($file, $dir); $file = convert($file); my $hash = hashFile($file); - print $OUT "$name <- $hash\n"; + $bindings{$name} = "Pkg(\"$hash\")"; + } elsif (/^(\w+)\s*:\s*([+\w\d\.\/-]+)\s*(\#.*)?$/) { + my $name = $1; + my $value = $2; + $bindings{$name} = "Str(\"$value\")"; } else { - print $OUT "$_\n"; + die "syntax error: $_"; } } - close $OUT; close $IN; + $bindings{"system"} = "Str(\"$system\")"; + + open $OUT, "| baffle -wt > $tmpfile" or die "cannot create $tmpfile"; + print $OUT "Descr(["; + my $first = 1; + foreach my $name (sort (keys %bindings)) { + if (!$first) { print $OUT ","; }; + print $OUT "Bind(\"$name\",$bindings{$name})"; + $first = 0; + } + print $OUT "])"; + close $OUT; + my $hash = hashFile($tmpfile); - my $outfile = "$outdir/$hash-$fn"; + my $outfile = "$outdir/$fn-$hash"; rename($tmpfile, $outfile) or die "cannot rename $tmpfile to $outfile"; $donetmpls{$descr} = $outfile; |