* Allow the resulting symlink of nix-build to be named, e.g.,
$ nix-build .../i686-linux.nix -A apacheHttpd -o apache
This commit is contained in:
		
							parent
							
								
									fdea084c36
								
							
						
					
					
						commit
						05bb644890
					
				
					 1 changed files with 31 additions and 9 deletions
				
			
		| 
						 | 
					@ -6,6 +6,9 @@ use strict;
 | 
				
			||||||
my $addDrvLink = 0;
 | 
					my $addDrvLink = 0;
 | 
				
			||||||
my $addOutLink = 1;
 | 
					my $addOutLink = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					my $outLink;
 | 
				
			||||||
 | 
					my $drvLink;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my @instArgs = ();
 | 
					my @instArgs = ();
 | 
				
			||||||
my @buildArgs = ();
 | 
					my @buildArgs = ();
 | 
				
			||||||
my @exprs = ();
 | 
					my @exprs = ();
 | 
				
			||||||
| 
						 | 
					@ -37,13 +40,15 @@ default to ./default.nix if none are given).  A symlink called
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Flags:
 | 
					Flags:
 | 
				
			||||||
  --add-drv-link: create a symlink `derivation' to the store derivation
 | 
					  --add-drv-link: create a symlink `derivation' to the store derivation
 | 
				
			||||||
 | 
					  --drv-link NAME: create symlink NAME instead of `derivation'
 | 
				
			||||||
  --no-out-link: do not create the `result' symlink
 | 
					  --no-out-link: do not create the `result' symlink
 | 
				
			||||||
 | 
					  --out-link / -o NAME: create symlink NAME instead of `result'
 | 
				
			||||||
  --attr ATTR: select a specific attribution from the Nix expression
 | 
					  --attr ATTR: select a specific attribution from the Nix expression
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Any additional flags are passed to `nix-store'.
 | 
					Any additional flags are passed to `nix-store'.
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
        exit 0;
 | 
					        exit 0;
 | 
				
			||||||
        # ' hack
 | 
					        # '` hack
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elsif ($arg eq "--add-drv-link") {
 | 
					    elsif ($arg eq "--add-drv-link") {
 | 
				
			||||||
| 
						 | 
					@ -54,6 +59,18 @@ EOF
 | 
				
			||||||
        $addOutLink = 1;
 | 
					        $addOutLink = 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elsif ($arg eq "--drv-link") {
 | 
				
			||||||
 | 
					        $n++;
 | 
				
			||||||
 | 
					        die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
 | 
				
			||||||
 | 
					        $drvLink = $ARGV[$n];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elsif ($arg eq "--out-link" or $arg eq "-o") {
 | 
				
			||||||
 | 
					        $n++;
 | 
				
			||||||
 | 
					        die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
 | 
				
			||||||
 | 
					        $outLink = $ARGV[$n];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elsif ($arg eq "--attr" or $arg eq "-A") {
 | 
					    elsif ($arg eq "--attr" or $arg eq "-A") {
 | 
				
			||||||
        $n++;
 | 
					        $n++;
 | 
				
			||||||
        die "$0: `--attr' requires an argument\n" unless $n < scalar @ARGV;
 | 
					        die "$0: `--attr' requires an argument\n" unless $n < scalar @ARGV;
 | 
				
			||||||
| 
						 | 
					@ -72,13 +89,21 @@ EOF
 | 
				
			||||||
@exprs = ("./default.nix") if scalar @exprs == 0;
 | 
					@exprs = ("./default.nix") if scalar @exprs == 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if (!defined $drvLink) {
 | 
				
			||||||
 | 
					    $drvLink = "derivation";
 | 
				
			||||||
 | 
					    $drvLink = ".nix-build-tmp-" . $drvLink if !$addDrvLink;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if (!defined $outLink) {
 | 
				
			||||||
 | 
					    $outLink = "result";
 | 
				
			||||||
 | 
					    $outLink = ".nix-build-tmp-" . $outLink if !$addOutLink;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
foreach my $expr (@exprs) {
 | 
					foreach my $expr (@exprs) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Instantiate.
 | 
					    # Instantiate.
 | 
				
			||||||
    my $prefix = "";
 | 
					    my $drvPaths = `@bindir@/nix-instantiate --add-root "$drvLink" --indirect @instArgs "$expr"`;
 | 
				
			||||||
    $prefix = ".nix-build-tmp-" if !$addDrvLink;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    my $drvPaths = `@bindir@/nix-instantiate --add-root ./${prefix}derivation --indirect @instArgs "$expr"`;
 | 
					 | 
				
			||||||
    my @drvPaths = split ' ', $drvPaths;
 | 
					    my @drvPaths = split ' ', $drvPaths;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    foreach my $drvPath (@drvPaths) {
 | 
					    foreach my $drvPath (@drvPaths) {
 | 
				
			||||||
| 
						 | 
					@ -87,10 +112,7 @@ foreach my $expr (@exprs) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Build.
 | 
					    # Build.
 | 
				
			||||||
    $prefix = "";
 | 
					    my $outPaths = `@bindir@/nix-store --add-root "$outLink" --indirect -rv @buildArgs @drvPaths`;
 | 
				
			||||||
    $prefix = ".nix-build-tmp-" if !$addOutLink;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    my $outPaths = `@bindir@/nix-store --add-root ./${prefix}result --indirect -rv @buildArgs @drvPaths`;
 | 
					 | 
				
			||||||
    my @outPaths = split ' ', $outPaths;
 | 
					    my @outPaths = split ' ', $outPaths;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    foreach my $outPath (@outPaths) {
 | 
					    foreach my $outPath (@outPaths) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue