getSourceExpr(): Handle channels
Fixes #1892. Fixes #1865. Fixes #3119. (cherry picked from commit e6e61f0a54dac0174df996e93fcfedcac7769ab4)
This commit is contained in:
		
							parent
							
								
									22d4ea7a98
								
							
						
					
					
						commit
						1d5cb6ad48
					
				
					 1 changed files with 16 additions and 15 deletions
				
			
		| 
						 | 
					@ -45,25 +45,26 @@ Value * SourceExprCommand::getSourceExpr(EvalState & state)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        std::unordered_set<std::string> seen;
 | 
					        std::unordered_set<std::string> seen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (auto & i : searchPath) {
 | 
					        auto addEntry = [&](const std::string & name) {
 | 
				
			||||||
            if (i.first == "") continue;
 | 
					            if (name == "") return;
 | 
				
			||||||
            if (seen.count(i.first)) continue;
 | 
					            if (!seen.insert(name).second) return;
 | 
				
			||||||
            seen.insert(i.first);
 | 
					 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
            auto res = state.resolveSearchPathElem(i);
 | 
					 | 
				
			||||||
            if (!res.first) continue;
 | 
					 | 
				
			||||||
            if (!pathExists(res.second)) continue;
 | 
					 | 
				
			||||||
            mkApp(*state.allocAttr(*vSourceExpr, state.symbols.create(i.first)),
 | 
					 | 
				
			||||||
                state.getBuiltin("import"),
 | 
					 | 
				
			||||||
                mkString(*state.allocValue(), res.second));
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
            Value * v1 = state.allocValue();
 | 
					            Value * v1 = state.allocValue();
 | 
				
			||||||
            mkPrimOpApp(*v1, state.getBuiltin("findFile"), state.getBuiltin("nixPath"));
 | 
					            mkPrimOpApp(*v1, state.getBuiltin("findFile"), state.getBuiltin("nixPath"));
 | 
				
			||||||
            Value * v2 = state.allocValue();
 | 
					            Value * v2 = state.allocValue();
 | 
				
			||||||
            mkApp(*v2, *v1, mkString(*state.allocValue(), i.first));
 | 
					            mkApp(*v2, *v1, mkString(*state.allocValue(), name));
 | 
				
			||||||
            mkApp(*state.allocAttr(*vSourceExpr, state.symbols.create(i.first)),
 | 
					            mkApp(*state.allocAttr(*vSourceExpr, state.symbols.create(name)),
 | 
				
			||||||
                state.getBuiltin("import"), *v2);
 | 
					                state.getBuiltin("import"), *v2);
 | 
				
			||||||
        }
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (auto & i : searchPath)
 | 
				
			||||||
 | 
					            /* Hack to handle channels. */
 | 
				
			||||||
 | 
					            if (i.first.empty() && pathExists(i.second + "/manifest.nix")) {
 | 
				
			||||||
 | 
					                for (auto & j : readDirectory(i.second))
 | 
				
			||||||
 | 
					                    if (j.name != "manifest.nix"
 | 
				
			||||||
 | 
					                        && pathExists(fmt("%s/%s/default.nix", i.second, j.name)))
 | 
				
			||||||
 | 
					                        addEntry(j.name);
 | 
				
			||||||
 | 
					            } else
 | 
				
			||||||
 | 
					                addEntry(i.first);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        vSourceExpr->attrs->sort();
 | 
					        vSourceExpr->attrs->sort();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue