core/pkgs/by-name/tc/tcl/generic.nix

101 lines
2.6 KiB
Nix
Raw Normal View History

2024-06-30 08:16:52 +00:00
{
lib,
stdenv,
callPackage,
makeSetupHook,
runCommand,
tzdata,
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
# Version specific stuff
release,
version,
src,
...
2024-05-02 00:46:19 +00:00
}:
let
2024-06-30 08:16:52 +00:00
baseInterp = stdenv.mkDerivation rec {
pname = "tcl";
inherit version src;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
outputs = [
"out"
"man"
];
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
setOutputFlags = false;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
postPatch = ''
substituteInPlace library/clock.tcl \
--replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo" \
--replace "/usr/share/lib/zoneinfo" "" \
--replace "/usr/lib/zoneinfo" "" \
--replace "/usr/local/etc/zoneinfo" ""
'';
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
preConfigure = ''
cd unix
'';
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
configureFlags = [
"--enable-threads"
# Note: using $out instead of $man to prevent a runtime dependency on $man.
"--mandir=${placeholder "out"}/share/man"
"--enable-man-symlinks"
# Don't install tzdata because NixOS already has a more up-to-date copy.
"--with-tzdata=no"
"tcl_cv_strtod_unbroken=ok"
] ++ lib.optional stdenv.is64bit "--enable-64bit";
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
enableParallelBuilding = true;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
postInstall =
let
2024-05-02 00:46:19 +00:00
dllExtension = stdenv.hostPlatform.extensions.sharedLibrary;
2024-06-30 08:16:52 +00:00
in
''
2024-05-02 00:46:19 +00:00
make install-private-headers
ln -s $out/bin/tclsh${release} $out/bin/tclsh
ln -s $out/lib/libtcl${release}${dllExtension} $out/lib/libtcl${dllExtension}
'';
2024-06-30 08:16:52 +00:00
meta = with lib; {
description = "The Tcl scripting language";
homepage = "https://www.tcl.tk/";
license = licenses.tcltk;
platforms = platforms.all;
maintainers = with maintainers; [ agbrooks ];
};
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
passthru = rec {
inherit release version;
libPrefix = "tcl${release}";
libdir = "lib/${libPrefix}";
tclPackageHook = callPackage (
{ buildPackages }:
makeSetupHook {
2024-05-02 00:46:19 +00:00
name = "tcl-package-hook";
propagatedBuildInputs = [ buildPackages.makeBinaryWrapper ];
meta = {
inherit (meta) maintainers platforms;
};
2024-06-30 08:16:52 +00:00
} ./tcl-package-hook.sh
) { };
# verify that Tcl's clock library can access tzdata
tests.tzdata = runCommand "${pname}-test-tzdata" { } ''
${baseInterp}/bin/tclsh <(echo "set t [clock scan {2004-10-30 05:00:00} \
-format {%Y-%m-%d %H:%M:%S} \
-timezone :America/New_York]") > $out
'';
2024-05-02 00:46:19 +00:00
};
2024-06-30 08:16:52 +00:00
};
2024-05-02 00:46:19 +00:00
mkTclDerivation = callPackage ./mk-tcl-derivation.nix { tcl = baseInterp; };
2024-06-30 08:16:52 +00:00
in
baseInterp.overrideAttrs (self: {
passthru = self.passthru // {
inherit mkTclDerivation;
};
2024-05-02 00:46:19 +00:00
})