1# Generic builder for tcl packages/applications, generally based on mk-python-derivation.nix
2{
3 tcl,
4 lib,
5 makeWrapper,
6 runCommand,
7 writeScript,
8}:
9
10{
11 buildInputs ? [ ],
12 nativeBuildInputs ? [ ],
13 propagatedBuildInputs ? [ ],
14 checkInputs ? [ ],
15 nativeCheckInputs ? [ ],
16
17 # true if we should skip the configuration phase altogether
18 dontConfigure ? false,
19
20 # Extra flags passed to configure step
21 configureFlags ? [ ],
22
23 # Whether or not we should add common Tcl-related configure flags
24 addTclConfigureFlags ? true,
25
26 meta ? { },
27 passthru ? { },
28 doCheck ? true,
29 ...
30}@attrs:
31
32let
33 inherit (tcl) stdenv;
34 inherit (lib) getBin optionalAttrs;
35
36 defaultTclPkgConfigureFlags = [
37 "--with-tcl=${tcl}/lib"
38 "--with-tclinclude=${tcl}/include"
39 "--exec-prefix=${placeholder "out"}"
40 ];
41
42 self = (
43 stdenv.mkDerivation (
44 (builtins.removeAttrs attrs [
45 "addTclConfigureFlags"
46 "checkPhase"
47 "checkInputs"
48 "nativeCheckInputs"
49 "doCheck"
50 ])
51 // {
52
53 buildInputs = buildInputs ++ [ tcl.tclPackageHook ];
54 nativeBuildInputs = nativeBuildInputs ++ [
55 makeWrapper
56 tcl
57 ];
58 propagatedBuildInputs = propagatedBuildInputs ++ [ tcl ];
59
60 TCLSH = "${getBin tcl}/bin/tclsh";
61
62 # Run tests after install, at which point we've done all TCLLIBPATH setup
63 doCheck = false;
64 doInstallCheck = attrs.doCheck or (attrs.doInstallCheck or false);
65 installCheckInputs = checkInputs ++ (attrs.installCheckInputs or [ ]);
66 nativeInstallCheckInputs = nativeCheckInputs ++ (attrs.nativeInstallCheckInputs or [ ]);
67
68 # Add typical values expected by TEA for configureFlags
69 configureFlags =
70 if (!dontConfigure && addTclConfigureFlags) then
71 (configureFlags ++ defaultTclPkgConfigureFlags)
72 else
73 configureFlags;
74
75 meta = {
76 platforms = tcl.meta.platforms;
77 }
78 // meta;
79
80 }
81 // optionalAttrs (attrs ? checkPhase) {
82 installCheckPhase = attrs.checkPhase;
83 }
84 )
85 );
86
87in
88lib.extendDerivation true passthru self