mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 21:50:55 +00:00
c6ca1ba9c7
Implement tclPackageHook, a setup hook that adjusts TCLLIBPATH to include the paths of any installed Tcl packages, propagates that TCLLIBPATH to anti-dependencies, and wraps any installed binaries to set their TCLLIBPATH. Additionally, implement a makePythonPackage-style mkDerivation wrapper to use reasonable defaults for Tcl packages and use tclPackageHook.
70 lines
1.8 KiB
Nix
70 lines
1.8 KiB
Nix
# Generic builder for tcl packages/applications, generally based on mk-python-derivation.nix
|
|
{ tcl
|
|
, lib
|
|
, makeWrapper
|
|
, runCommand
|
|
, writeScript
|
|
}:
|
|
|
|
{ buildInputs ? []
|
|
, nativeBuildInputs ? []
|
|
, propagatedBuildInputs ? []
|
|
, checkInputs ? []
|
|
|
|
# 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 optionals;
|
|
|
|
defaultTclPkgConfigureFlags = [
|
|
"--with-tcl=${tcl}/lib"
|
|
"--with-tclinclude=${tcl}/include"
|
|
"--exec-prefix=\${out}"
|
|
];
|
|
|
|
self = (stdenv.mkDerivation ((builtins.removeAttrs attrs [
|
|
"addTclConfigureFlags" "checkPhase" "checkInputs" "doCheck"
|
|
]) // {
|
|
|
|
buildInputs = buildInputs ++ [ makeWrapper tcl.tclPackageHook ];
|
|
nativeBuildInputs = nativeBuildInputs ++ [ tcl ];
|
|
propagatedBuildInputs = propagatedBuildInputs ++ [ tcl ];
|
|
|
|
TCLSH = "${getBin tcl}/bin/tclsh";
|
|
|
|
# Run tests after install, at which point we've done all TCLLIBPATH setup
|
|
doCheck = false;
|
|
doInstallCheck = attrs.doCheck or ((attrs ? doInstallCheck) && attrs.doInstallCheck);
|
|
installCheckInputs = checkInputs ++ (optionals (attrs ? installCheckInputs) attrs.installCheckInputs);
|
|
|
|
# Add typical values expected by TEA for configureFlags
|
|
configureFlags =
|
|
if (!dontConfigure && addTclConfigureFlags)
|
|
then (configureFlags ++ defaultTclPkgConfigureFlags)
|
|
else configureFlags;
|
|
|
|
meta = {
|
|
platforms = tcl.meta.platforms;
|
|
} // meta;
|
|
|
|
|
|
} // optionalAttrs (attrs?checkPhase) {
|
|
installCheckPhase = attrs.checkPhase;
|
|
}
|
|
));
|
|
|
|
in lib.extendDerivation true passthru self
|