* Dirty hack to make nix-push work properly on derivations: the
derivation should be a source rather than a derivation dependency of the call to the NAR derivation. Otherwise the derivation (and all its dependencies) will be built as a side-effect, which may not even succeed.
This commit is contained in:
		
							parent
							
								
									82ae85de27
								
							
						
					
					
						commit
						f8713e1287
					
				
					 2 changed files with 24 additions and 10 deletions
				
			
		|  | @ -128,7 +128,7 @@ while (<READ>) { | ||||||
| close READ or die "nix-instantiate failed: $?"; | close READ or die "nix-instantiate failed: $?"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Realise the store expressions. | # Build the derivations. | ||||||
| print STDERR "creating archives...\n"; | print STDERR "creating archives...\n"; | ||||||
| 
 | 
 | ||||||
| my @narPaths; | my @narPaths; | ||||||
|  | @ -144,7 +144,6 @@ while (scalar @tmp > 0) { | ||||||
|     # reference (see above).  Even if that is fixed, using a hook |     # reference (see above).  Even if that is fixed, using a hook | ||||||
|     # probably wouldn't make that much sense; pumping lots of data |     # probably wouldn't make that much sense; pumping lots of data | ||||||
|     # around just to compress them won't gain that much. |     # around just to compress them won't gain that much. | ||||||
|     $ENV{"NIX_BUILD_HOOK"} = ""; |  | ||||||
|     my $pid = open(READ, "$binDir/nix-store --no-build-hook --realise @tmp2|") |     my $pid = open(READ, "$binDir/nix-store --no-build-hook --realise @tmp2|") | ||||||
|         or die "cannot run nix-store"; |         or die "cannot run nix-store"; | ||||||
|     while (<READ>) { |     while (<READ>) { | ||||||
|  |  | ||||||
|  | @ -366,12 +366,18 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) | ||||||
|        attributes should be added as dependencies of the resulting |        attributes should be added as dependencies of the resulting | ||||||
|        derivation. */ |        derivation. */ | ||||||
|     for (PathSet::iterator i = context.begin(); i != context.end(); ++i) { |     for (PathSet::iterator i = context.begin(); i != context.end(); ++i) { | ||||||
|         debug(format("derivation uses `%1%'") % *i); |         Path path = *i; | ||||||
|         assert(isStorePath(*i)); |         bool buildDrv = true; | ||||||
|         if (isDerivation(*i)) |         if (path.at(0) == '=') { | ||||||
|             drv.inputDrvs[*i] = singleton<StringSet>("out"); |             buildDrv = false; | ||||||
|  |             path = string(path, 1); | ||||||
|  |         } | ||||||
|  |         debug(format("derivation uses `%1%'") % path); | ||||||
|  |         assert(isStorePath(path)); | ||||||
|  |         if (buildDrv && isDerivation(path)) | ||||||
|  |             drv.inputDrvs[path] = singleton<StringSet>("out"); | ||||||
|         else |         else | ||||||
|             drv.inputSrcs.insert(*i); |             drv.inputSrcs.insert(path); | ||||||
|     } |     } | ||||||
|              |              | ||||||
|     /* Do we have all required attributes? */ |     /* Do we have all required attributes? */ | ||||||
|  | @ -498,9 +504,17 @@ static Expr prim_storePath(EvalState & state, const ATermVector & args) | ||||||
|     Path path = canonPath(coerceToPath(state, args[0], context)); |     Path path = canonPath(coerceToPath(state, args[0], context)); | ||||||
|     if (!isInStore(path)) |     if (!isInStore(path)) | ||||||
|         throw EvalError(format("path `%1%' is not in the Nix store") % path); |         throw EvalError(format("path `%1%' is not in the Nix store") % path); | ||||||
|     if (!store->isValidPath(path)) |     Path path2 = toStorePath(path); | ||||||
|         throw EvalError(format("store path `%1%' is not valid") % path); |     if (!store->isValidPath(path2)) | ||||||
|     context.insert(toStorePath(path)); |         throw EvalError(format("store path `%1%' is not valid") % path2); | ||||||
|  |     /* If this is a derivation, mark it so it doesn't get built;
 | ||||||
|  |        i.e. we want the dependency as a "source" dependency.  This is | ||||||
|  |        to make nix-push work properly (we want it to create a NAR | ||||||
|  |        archive of the derivation, not build the derivation as a | ||||||
|  |        side-effect).  The `=' is a special marker that gets stripped | ||||||
|  |        off by prim_derivationStrict. */ | ||||||
|  |     if (isDerivation(path2)) path2 = "=" + path2; | ||||||
|  |     context.insert(path2); | ||||||
|     return makeStr(path, context); |     return makeStr(path, context); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -578,6 +592,7 @@ static Expr prim_toFile(EvalState & state, const ATermVector & args) | ||||||
|     for (PathSet::iterator i = context.begin(); i != context.end(); ++i) { |     for (PathSet::iterator i = context.begin(); i != context.end(); ++i) { | ||||||
|         if (isDerivation(*i)) |         if (isDerivation(*i)) | ||||||
|             throw EvalError(format("in `toFile': the file `%1%' cannot refer to derivation outputs") % name); |             throw EvalError(format("in `toFile': the file `%1%' cannot refer to derivation outputs") % name); | ||||||
|  |         /* !!! */ | ||||||
|         refs.insert(*i); |         refs.insert(*i); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue