nix-shell/nix-build: Support .drv files again
Fixes #1663. Also handle '!<output-name>' (#1694).
This commit is contained in:
		
							parent
							
								
									0fc3e581e0
								
							
						
					
					
						commit
						90948a4e3a
					
				
					 6 changed files with 61 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#include "get-drvs.hh"
 | 
			
		||||
#include "util.hh"
 | 
			
		||||
#include "eval-inline.hh"
 | 
			
		||||
#include "derivations.hh"
 | 
			
		||||
 | 
			
		||||
#include <cstring>
 | 
			
		||||
#include <regex>
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +16,33 @@ DrvInfo::DrvInfo(EvalState & state, const string & attrPath, Bindings * attrs)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DrvInfo::DrvInfo(EvalState & state, ref<Store> store, const std::string & drvPathWithOutputs)
 | 
			
		||||
    : state(&state), attrs(nullptr), attrPath("")
 | 
			
		||||
{
 | 
			
		||||
    auto spec = parseDrvPathWithOutputs(drvPathWithOutputs);
 | 
			
		||||
 | 
			
		||||
    drvPath = spec.first;
 | 
			
		||||
 | 
			
		||||
    auto drv = store->derivationFromPath(drvPath);
 | 
			
		||||
 | 
			
		||||
    name = storePathToName(drvPath);
 | 
			
		||||
 | 
			
		||||
    if (spec.second.size() > 1)
 | 
			
		||||
        throw Error("building more than one derivation output is not supported, in '%s'", drvPathWithOutputs);
 | 
			
		||||
 | 
			
		||||
    outputName =
 | 
			
		||||
        spec.second.empty()
 | 
			
		||||
        ? get(drv.env, "outputName", "out")
 | 
			
		||||
        : *spec.second.begin();
 | 
			
		||||
 | 
			
		||||
    auto i = drv.outputs.find(outputName);
 | 
			
		||||
    if (i == drv.outputs.end())
 | 
			
		||||
        throw Error("derivation '%s' does not have output '%s'", drvPath, outputName);
 | 
			
		||||
 | 
			
		||||
    outPath = i->second.path;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
string DrvInfo::queryName() const
 | 
			
		||||
{
 | 
			
		||||
    if (name == "" && attrs) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue