resholve: fix finalAttrs compatibility

This commit is contained in:
Travis A. Everett
2026-05-09 15:55:12 -05:00
parent 17537fe156
commit 62e9404388
3 changed files with 53 additions and 46 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ trivial, so I'll also link to some real-world examples:
## Basic `resholve.phraseSolution` example
This function has a similar API to `writeScript` and `writeScriptBin`, except it does require a `scripts` attr. It is intended to make resholve a little easier to mix into more types of builds. This example is a little
This function has a similar API to `writeScript` and `writeScriptBin`, except it does require a `scripts` attr. It is intended to make resholve a little easier to mix into more types of build. This example is a little
trivial for now. If you have a real usage that you find helpful, please PR it.
```nix
@@ -219,50 +219,54 @@ rec {
)}
'';
};
mkDerivation =
{
pname,
src,
version,
passthru ? { },
solutions,
postResholve ? "",
...
}@attrs:
let
inherit stdenv;
/*
This uses nested derivations so we can:
- let project build however it needs in inner "unresholved" drv
- pass this drv through binlore to collect info on exec behavior
in any scripts and binaries in its output
- resholve with lore unresholved source and lore as inputs
/*
Knock out our special solutions arg, but otherwise
just build what the caller is giving us. We'll
actually resholve it separately below (after we
generate binlore for it).
*/
unresholved = (
stdenv.mkDerivation (
(removeAttrs attrs [ "solutions" ])
// {
inherit version src;
pname = "${pname}-unresholved";
}
)
);
in
/*
resholve in a separate derivation; some concerns:
- we aren't keeping many of the user's args, so they
can't readily set LOGLEVEL and such...
- not sure how this affects multiple outputs
*/
lib.extendDerivation true passthru (
some concerns:
- resholve drv isn't keeping many of the caller's args,
(to avoid re-triggering phases and such in outer build)
so they can't readily set LOGLEVEL and such...
- not sure how this affects multiple outputs
*/
mkDerivation = lib.extendMkDerivation {
constructDrv = stdenv.mkDerivation;
excludeDrvArgNames = [
"postResholve"
"solutions"
];
extendDrvArgs =
finalAttrs:
{
pname,
src,
version,
passthru ? { },
solutions,
postResholve ? "",
...
}@args:
{
pname = "${pname}-unresholved";
passthru = passthru // {
# needed to resholve in outer drv
inherit postResholve solutions;
};
};
transformDrv =
unresholved:
stdenv.mkDerivation {
src = unresholved;
inherit version pname;
pname = lib.removeSuffix "-unresholved" unresholved.pname;
inherit (unresholved) version;
buildInputs = [ resholve ];
disallowedReferences = [ resholve ];
# retain a reference to the base
passthru = unresholved.passthru // {
# retain a reference to the base
unresholved = unresholved;
# fallback attr for update bot to query our src
originalSrc = unresholved.src;
@@ -279,12 +283,12 @@ rec {
# enable below for verbose debug info if needed
# supports default python.logging levels
# LOGLEVEL="INFO";
preFixup = phraseSolutions solutions unresholved;
preFixup = phraseSolutions unresholved.solutions unresholved;
postFixup = postResholve;
postFixup = unresholved.postResholve;
# don't break the metadata...
meta = unresholved.meta;
}
);
};
};
}
+7 -4
View File
@@ -82,7 +82,7 @@ let
];
in
rec {
module1 = resholve.mkDerivation {
module1 = resholve.mkDerivation(finalAttrs: {
pname = "testmod1";
version = "unreleased";
@@ -111,8 +111,9 @@ rec {
};
};
is_it_okay_with_arbitrary_envs = "shonuff";
};
# finalAttrs proof-of-life
passthru.version = finalAttrs.version;
});
module2 = resholve.mkDerivation {
pname = "testmod2";
version = "unreleased";
@@ -335,7 +336,9 @@ rec {
inherit msmtp;
inherit nix-direnv;
inherit pdf2odt;
inherit pdfmm;
# TODO: re-enable when safe; disabled may 9 2026 due
# to build failure down in pdfmm > zenity > appstream
# inherit pdfmm;
inherit shunit2;
inherit xdg-utils;
inherit yadm;