nix-prefetch-url -A: Use "name" attribute from Nix expression
This is in particular useful for fetchFromGitHub et al., ensuring that the store path produced by nix-prefetch-url corresponds to what those functions expect.
This commit is contained in:
		
							parent
							
								
									b54f447df9
								
							
						
					
					
						commit
						e4abf8610b
					
				
					 1 changed files with 8 additions and 1 deletions
				
			
		|  | @ -54,6 +54,7 @@ int main(int argc, char * * argv) | ||||||
|         string attrPath; |         string attrPath; | ||||||
|         std::map<string, string> autoArgs_; |         std::map<string, string> autoArgs_; | ||||||
|         bool unpack = false; |         bool unpack = false; | ||||||
|  |         string name; | ||||||
| 
 | 
 | ||||||
|         parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) { |         parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) { | ||||||
|             if (*arg == "--help") |             if (*arg == "--help") | ||||||
|  | @ -122,10 +123,16 @@ int main(int argc, char * * argv) | ||||||
|                 printMsg(lvlInfo, "warning: this does not look like a fetchurl call"); |                 printMsg(lvlInfo, "warning: this does not look like a fetchurl call"); | ||||||
|             else |             else | ||||||
|                 unpack = state.forceString(*attr->value) == "recursive"; |                 unpack = state.forceString(*attr->value) == "recursive"; | ||||||
|  | 
 | ||||||
|  |             /* Extract the name. */ | ||||||
|  |             attr = v.attrs->find(state.symbols.create("name")); | ||||||
|  |             if (attr != v.attrs->end()) | ||||||
|  |                 name = state.forceString(*attr->value); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /* Figure out a name in the Nix store. */ |         /* Figure out a name in the Nix store. */ | ||||||
|         auto name = baseNameOf(uri); |         if (name.empty()) | ||||||
|  |             name = baseNameOf(uri); | ||||||
|         if (name.empty()) |         if (name.empty()) | ||||||
|             throw Error(format("cannot figure out file name for ‘%1%’") % uri); |             throw Error(format("cannot figure out file name for ‘%1%’") % uri); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue