resholve: fix finalAttrs compatibility (#519440)

This commit is contained in:
Yueh-Shun Li
2026-05-16 04:32:08 +00:00
committed by GitHub
15 changed files with 95 additions and 92 deletions
+3 -3
View File
@@ -17,14 +17,14 @@
resholve,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "aaxtomp3";
version = "1.3";
src = fetchFromGitHub {
owner = "krumpetpirate";
repo = "aaxtomp3";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-7a9ZVvobWH/gPxa3cFiPL+vlu8h1Dxtcq0trm3HzlQg=";
};
@@ -76,4 +76,4 @@ resholve.mkDerivation rec {
license = lib.licenses.wtfpl;
maintainers = [ ];
};
}
})
@@ -22,7 +22,7 @@
chrootSetprivPath ? "/usr/bin/setpriv",
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "arch-install-scripts";
version = "31";
@@ -30,7 +30,7 @@ resholve.mkDerivation rec {
domain = "gitlab.archlinux.org";
owner = "archlinux";
repo = "arch-install-scripts";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-Oh1nC/gPJDDy8cXiZPbEfpwOuO+RFRcxVCZuTtB2MV8=";
};
@@ -121,4 +121,4 @@ resholve.mkDerivation rec {
maintainers = with lib.maintainers; [ samlukeyes123 ];
platforms = lib.platforms.linux;
};
}
})
+4 -4
View File
@@ -27,14 +27,14 @@
packcc,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "bats";
version = "1.12.0";
src = fetchFromGitHub {
owner = "bats-core";
repo = "bats-core";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-5VCkOzyaUOBW+HVVHDkH9oCWDI/MJW6yrLTQG60Ralk=";
};
@@ -153,7 +153,7 @@ resholve.mkDerivation rec {
--suffix BATS_LIB_PATH : "$out/share/bats"
'';
inherit meta;
meta = removeAttrs finalAttrs.meta [ "position" ];
};
passthru.tests = {
@@ -281,4 +281,4 @@ resholve.mkDerivation rec {
license = lib.licenses.mit;
platforms = lib.platforms.unix;
};
}
})
+4 -4
View File
@@ -8,7 +8,7 @@
which,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "dgoss";
version = goss.version;
src = goss.src;
@@ -37,8 +37,8 @@ resholve.mkDerivation rec {
};
meta = {
homepage = "https://github.com/goss-org/goss/blob/v${version}/extras/dgoss/README.md";
changelog = "https://github.com/goss-org/goss/releases/tag/v${version}";
homepage = "https://github.com/goss-org/goss/blob/v${finalAttrs.version}/extras/dgoss/README.md";
changelog = "https://github.com/goss-org/goss/releases/tag/v${finalAttrs.version}";
description = "Convenience wrapper around goss that aims to bring the simplicity of goss to docker containers";
license = lib.licenses.asl20;
platforms = lib.platforms.linux;
@@ -48,4 +48,4 @@ resholve.mkDerivation rec {
];
mainProgram = "dgoss";
};
}
})
+3 -3
View File
@@ -17,13 +17,13 @@
man,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "git-ftp";
version = "1.6.0";
src = fetchFromGitHub {
owner = "git-ftp";
repo = "git-ftp";
rev = version;
rev = finalAttrs.version;
sha256 = "1hxkqf7jbrx24q18yxpnd3dxzh4xk6asymwkylp1x7zg6mcci87d";
};
@@ -101,4 +101,4 @@ resholve.mkDerivation rec {
platforms = lib.platforms.unix;
mainProgram = "git-ftp";
};
}
})
+3 -5
View File
@@ -7,16 +7,14 @@
writeText,
}:
# resholve does not yet support `finalAttrs` call pattern hence `rec`
# https://github.com/abathur/resholve/issues/107
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "nix-direnv";
version = "3.1.1";
src = fetchFromGitHub {
owner = "nix-community";
repo = "nix-direnv";
rev = version;
rev = finalAttrs.version;
hash = "sha256-AsWnRH7LAb78iFfE+ZdYyCR5AVuPloT8ZnghDXW6arY=";
};
@@ -77,4 +75,4 @@ resholve.mkDerivation rec {
bbenne10
];
};
}
})
+4 -4
View File
@@ -30,14 +30,14 @@
stateDir ? "/etc/pihole",
}:
(resholve.mkDerivation rec {
(resholve.mkDerivation (finalAttrs: {
pname = "pihole";
version = "6.4";
src = fetchFromGitHub {
owner = "pi-hole";
repo = "pi-hole";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-aBQO+wAqeuXc9ekByVFlOZQ9SBCGsozGdoS8r1qhGuk=";
};
@@ -234,7 +234,7 @@
meta = {
description = "Black hole for Internet advertisements";
homepage = "https://pi-hole.net";
changelog = "https://github.com/pi-hole/pi-hole/releases/tag/v${version}";
changelog = "https://github.com/pi-hole/pi-hole/releases/tag/v${finalAttrs.version}";
license = lib.licenses.eupl12;
maintainers = with lib.maintainers; [ averyvigolo ];
platforms = lib.platforms.linux;
@@ -244,7 +244,7 @@
passthru.tests = nixosTests.pihole-ftl;
passthru = { inherit stateDir; };
}).overrideAttrs
})).overrideAttrs
(old: {
# Resholve can't fix the hardcoded absolute paths, so substitute them before resholving
preFixup = ''
+3 -3
View File
@@ -10,14 +10,14 @@
ncurses,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "shunit2";
version = "2.1.8";
src = fetchFromGitHub {
owner = "kward";
repo = "shunit2";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-IZHkgkVqzeh+eEKCDJ87sqNhSA+DU6kBCNDdQaUEeiM=";
};
@@ -102,4 +102,4 @@ resholve.mkDerivation rec {
platforms = lib.platforms.unix;
mainProgram = "shunit2";
};
}
})
@@ -19,14 +19,12 @@
which,
}:
# resholve does not yet support `finalAttrs` call pattern hence `rec`
# https://github.com/abathur/resholve/issues/107
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "unix-privesc-check";
version = "1.4";
src = fetchurl {
url = "https://pentestmonkey.net/tools/unix-privesc-check/unix-privesc-check-${version}.tar.gz";
url = "https://pentestmonkey.net/tools/unix-privesc-check/unix-privesc-check-${finalAttrs.version}.tar.gz";
hash = "sha256-4fhef2n6ut0jdWo9dqDj2GSyHih2O2DOLmGBKQ0cGWk=";
};
@@ -85,4 +83,4 @@ resholve.mkDerivation rec {
platforms = lib.platforms.unix;
license = lib.licenses.gpl2Plus;
};
}
})
+3 -3
View File
@@ -12,14 +12,14 @@
wireguard-tools,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "wgnord";
version = "0.2.1";
src = fetchFromGitHub {
owner = "phirecc";
repo = "wgnord";
rev = version;
rev = finalAttrs.version;
hash = "sha256-26cfYXtZVQ7kIRxY6oNGCqIjdw/hjwXhVKimVgolLgk=";
};
@@ -64,4 +64,4 @@ resholve.mkDerivation rec {
mainProgram = "wgnord";
platforms = lib.platforms.linux;
};
}
})
+5 -5
View File
@@ -28,7 +28,7 @@
yadm,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "yadm";
version = "3.5.0";
@@ -37,7 +37,7 @@ resholve.mkDerivation rec {
src = fetchFromGitHub {
owner = "yadm-dev";
repo = "yadm";
rev = version;
rev = finalAttrs.version;
hash = "sha256-hDo6zs70apNhKmuvR+eD51FzuTLj3SL/wHQXqLMD9QE=";
};
@@ -118,7 +118,7 @@ resholve.mkDerivation rec {
};
passthru.tests = {
minimal = runCommand "${pname}-test" { } ''
minimal = runCommand "${finalAttrs.pname}-test" { } ''
export HOME=$out
${yadm}/bin/yadm init
'';
@@ -133,10 +133,10 @@ resholve.mkDerivation rec {
* Provides a way to use alternate files on a specific OS or host.
* Supplies a method of encrypting confidential data so it can safely be stored in your repository.
'';
changelog = "https://github.com/yadm-dev/yadm/blob/${version}/CHANGES";
changelog = "https://github.com/yadm-dev/yadm/blob/${finalAttrs.version}/CHANGES";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ abathur ];
platforms = lib.platforms.unix;
mainProgram = "yadm";
};
}
})
+4 -4
View File
@@ -14,14 +14,14 @@
zfs,
}:
resholve.mkDerivation rec {
resholve.mkDerivation (finalAttrs: {
pname = "zxfer";
version = "1.1.7";
src = fetchFromGitHub {
owner = "allanjude";
repo = "zxfer";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-11SQJcD3GqPYBIgaycyKkc62/diVKPuuj2Or97j+NZY=";
};
@@ -80,9 +80,9 @@ resholve.mkDerivation rec {
meta = {
description = "Popular script for managing ZFS snapshot replication";
homepage = "https://github.com/allanjude/zxfer";
changelog = "https://github.com/allanjude/zxfer/releases/tag/v${version}";
changelog = "https://github.com/allanjude/zxfer/releases/tag/v${finalAttrs.version}";
license = lib.licenses.bsd2;
maintainers = [ ];
mainProgram = "zxfer";
};
}
})
+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;