From 62e94043881ab31df765acff280a36b89ec76d9d Mon Sep 17 00:00:00 2001 From: "Travis A. Everett" Date: Sat, 9 May 2026 15:55:12 -0500 Subject: [PATCH] resholve: fix finalAttrs compatibility --- pkgs/development/misc/resholve/README.md | 2 +- .../misc/resholve/resholve-utils.nix | 86 ++++++++++--------- pkgs/development/misc/resholve/test.nix | 11 ++- 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/pkgs/development/misc/resholve/README.md b/pkgs/development/misc/resholve/README.md index cef687d69a29..f137cdbbcc65 100644 --- a/pkgs/development/misc/resholve/README.md +++ b/pkgs/development/misc/resholve/README.md @@ -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 diff --git a/pkgs/development/misc/resholve/resholve-utils.nix b/pkgs/development/misc/resholve/resholve-utils.nix index 995e732631bd..e9350ed08e29 100644 --- a/pkgs/development/misc/resholve/resholve-utils.nix +++ b/pkgs/development/misc/resholve/resholve-utils.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; - } - ); + }; + }; } diff --git a/pkgs/development/misc/resholve/test.nix b/pkgs/development/misc/resholve/test.nix index 17124aeada6d..7c5c5e36d5b0 100644 --- a/pkgs/development/misc/resholve/test.nix +++ b/pkgs/development/misc/resholve/test.nix @@ -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;