Skip to content

Commit 55850e3

Browse files
committed
applyPatches: passthru common src attributes
This should enable tools like nix-update to update a patched src derivation.
1 parent 3fd3d5b commit 55850e3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

pkgs/build-support/trivial-builders/default.nix

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,16 @@ rec {
10281028
if patches == [ ] && prePatch == "" && postPatch == "" then
10291029
src # nothing to do, so use original src to avoid additional drv
10301030
else
1031+
let
1032+
keepAttrs = names: lib.filterAttrs (name: val: lib.elem name names);
1033+
# enables tools like nix-update to determine what src attributes to replace
1034+
extraPassthru = keepAttrs [
1035+
"rev"
1036+
"tag"
1037+
"url"
1038+
"outputHash"
1039+
] src;
1040+
in
10311041
stdenvNoCC.mkDerivation (
10321042
{
10331043
inherit
@@ -1042,11 +1052,19 @@ rec {
10421052
phases = "unpackPhase patchPhase installPhase";
10431053
installPhase = "cp -R ./ $out";
10441054
}
1045-
# Carry `meta` information from the underlying `src` if present.
1046-
// (optionalAttrs (src ? meta) { inherit (src) meta; })
1055+
# Carry and merge information from the underlying `src` if present.
1056+
// (optionalAttrs (src ? meta || args ? meta) {
1057+
meta = src.meta or { } // args.meta or { };
1058+
})
1059+
// (optionalAttrs (extraPassthru != { } || src ? passthru || args ? passthru) {
1060+
passthru = extraPassthru // src.passthru or { } // args.passthru or { };
1061+
})
1062+
# Forward any additional arguments to the derviation
10471063
// (removeAttrs args [
10481064
"src"
10491065
"name"
1066+
"meta"
1067+
"passthru"
10501068
"patches"
10511069
"prePatch"
10521070
"postPatch"

0 commit comments

Comments
 (0)