tcl.mkTclDerivation: use extendMkDerivation

This commit is contained in:
Francesco Gazzetta
2026-03-24 08:13:35 +01:00
parent ed684dccef
commit 1ca3a89b38
2 changed files with 45 additions and 56 deletions

View File

@@ -21,12 +21,12 @@ Here is a simple package example to be called with `tclPackages.callPackage`.
```
{ lib, fetchzip, mkTclDerivation, openssl }:
mkTclDerivation rec {
mkTclDerivation (finalAttrs: {
pname = "tcltls";
version = "1.7.22";
src = fetchzip {
url = "https://core.tcl-lang.org/tcltls/uv/tcltls-${version}.tar.gz";
url = "https://core.tcl-lang.org/tcltls/uv/tcltls-${finalAttrs.version}.tar.gz";
hash = "sha256-TOouWcQc3MNyJtaAGUGbaQoaCWVe6g3BPERct/V65vk=";
};
@@ -43,7 +43,7 @@ mkTclDerivation rec {
license = lib.licenses.tcltk;
platforms = lib.platforms.unix;
};
}
})
```
All Tcl libraries are declared in `pkgs/top-level/tcl-packages.nix` and are defined in `pkgs/development/tcl-modules/`.

View File

@@ -1,34 +1,10 @@
# Generic builder for tcl packages/applications, generally based on mk-python-derivation.nix
# Generic builder for tcl packages/applications
{
tcl,
lib,
makeWrapper,
runCommand,
writeScript,
}:
{
buildInputs ? [ ],
nativeBuildInputs ? [ ],
propagatedBuildInputs ? [ ],
checkInputs ? [ ],
nativeCheckInputs ? [ ],
# true if we should skip the configuration phase altogether
dontConfigure ? false,
# Extra flags passed to configure step
configureFlags ? [ ],
# Whether or not we should add common Tcl-related configure flags
addTclConfigureFlags ? true,
meta ? { },
passthru ? { },
doCheck ? true,
...
}@attrs:
let
inherit (tcl) stdenv;
inherit (lib) getBin optionalAttrs;
@@ -41,20 +17,35 @@ let
"--enable-stubs"
];
self = (
stdenv.mkDerivation (
(removeAttrs attrs [
"addTclConfigureFlags"
"checkPhase"
"checkInputs"
"nativeCheckInputs"
"doCheck"
])
// {
in
lib.extendMkDerivation {
constructDrv = stdenv.mkDerivation;
excludeDrvArgNames = [
"addTclConfigureFlags"
"checkPhase"
"checkInputs"
"nativeCheckInputs"
"doCheck"
];
extendDrvArgs =
finalAttrs:
args@{
# true if we should skip the configuration phase altogether
dontConfigure ? false,
# Extra flags passed to configure step
configureFlags ? [ ],
# Whether or not we should add common Tcl-related configure flags
addTclConfigureFlags ? true,
...
}:
(
{
buildInputs = args.buildInputs or [ ] ++ [ tcl.tclPackageHook ];
buildInputs = buildInputs ++ [ tcl.tclPackageHook ];
nativeBuildInputs =
nativeBuildInputs
args.nativeBuildInputs or [ ]
++ [
makeWrapper
tcl
@@ -62,18 +53,14 @@ let
++ lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
tcl.tclRequiresCheckHook
];
propagatedBuildInputs = propagatedBuildInputs ++ [ tcl ];
env = {
TCLSH = "${getBin tcl}/bin/tclsh";
}
// (attrs.env or { });
propagatedBuildInputs = args.propagatedBuildInputs or [ ] ++ [ tcl ];
# Run tests after install, at which point we've done all TCLLIBPATH setup
doCheck = false;
doInstallCheck = attrs.doCheck or (attrs.doInstallCheck or false);
installCheckInputs = checkInputs ++ (attrs.installCheckInputs or [ ]);
nativeInstallCheckInputs = nativeCheckInputs ++ (attrs.nativeInstallCheckInputs or [ ]);
doInstallCheck = args.doCheck or (args.doInstallCheck or false);
installCheckInputs = args.checkInputs or [ ] ++ args.installCheckInputs or [ ];
nativeInstallCheckInputs = args.nativeCheckInputs or [ ] ++ args.nativeInstallCheckInputs or [ ];
# Add typical values expected by TEA for configureFlags
configureFlags =
@@ -82,17 +69,19 @@ let
else
configureFlags;
env = {
TCLSH = "${getBin tcl}/bin/tclsh";
}
// args.env or { };
meta = {
platforms = tcl.meta.platforms;
}
// meta;
// args.meta or { };
}
// optionalAttrs (attrs ? checkPhase) {
installCheckPhase = attrs.checkPhase;
// optionalAttrs (args ? checkPhase) {
installCheckPhase = args.checkPhase;
}
)
);
in
lib.extendDerivation true passthru self
);
}