diff --git a/doc/languages-frameworks/tcl.section.md b/doc/languages-frameworks/tcl.section.md index 6c9f5c7e39c5..ff1a978304d3 100644 --- a/doc/languages-frameworks/tcl.section.md +++ b/doc/languages-frameworks/tcl.section.md @@ -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/`. diff --git a/pkgs/development/interpreters/tcl/mk-tcl-derivation.nix b/pkgs/development/interpreters/tcl/mk-tcl-derivation.nix index f29bf68451b0..33897cdd1c96 100644 --- a/pkgs/development/interpreters/tcl/mk-tcl-derivation.nix +++ b/pkgs/development/interpreters/tcl/mk-tcl-derivation.nix @@ -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 + ); +}