mirror of
https://github.com/NixOS/nix.git
synced 2025-11-29 21:50:58 +01:00
fetchTree: Support applying patches
You can now write
fetchTree {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
rev = "0f316e4d72daed659233817ffe52bf08e081b5de";
patches = [ ./thunderbird-1.patch ./thunderbird-2.patch ];
};
to apply a list of patches to a tree. These are applied lazily - the
patched tree is not materialized unless you do something that causes
the entire tree to be copied to the store (like 'src = fetchTree {
... }'). The equivalent of '-p1' is implied.
File additions/deletions/renames are not yet handled.
Issue #3920.
This commit is contained in:
parent
9075644631
commit
4b313ceb9e
6 changed files with 195 additions and 0 deletions
|
|
@ -105,6 +105,7 @@ static void fetchTree(
|
|||
) {
|
||||
fetchers::Input input;
|
||||
PathSet context;
|
||||
std::vector<std::string> patches;
|
||||
|
||||
state.forceValue(*args[0], pos);
|
||||
|
||||
|
|
@ -130,7 +131,22 @@ static void fetchTree(
|
|||
|
||||
for (auto & attr : *args[0]->attrs) {
|
||||
if (attr.name == state.sType) continue;
|
||||
|
||||
if (attr.name == "patches") {
|
||||
state.forceList(*attr.value, *attr.pos);
|
||||
|
||||
for (auto elem : attr.value->listItems()) {
|
||||
// FIXME: use realisePath
|
||||
PathSet context;
|
||||
auto patchFile = state.unpackPath(state.coerceToPath(pos, *elem, context));
|
||||
patches.push_back(patchFile.accessor->readFile(patchFile.path));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
state.forceValue(*attr.value, *attr.pos);
|
||||
|
||||
if (attr.value->type() == nPath || attr.value->type() == nString) {
|
||||
auto s = state.coerceToString(*attr.pos, *attr.value, context, false, false).toOwned();
|
||||
attrs.emplace(attr.name,
|
||||
|
|
@ -178,6 +194,9 @@ static void fetchTree(
|
|||
|
||||
auto [accessor, input2] = input.lazyFetch(state.store);
|
||||
|
||||
if (!patches.empty())
|
||||
accessor = makePatchingInputAccessor(accessor, patches);
|
||||
|
||||
//state.allowPath(tree.storePath);
|
||||
|
||||
emitTreeAttrs(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue