summary refs log tree commit diff
path: root/pkgs/development/interpreters/tcl/mk-tcl-derivation.nix
blob: 0e44eb35859350fbef132b732a6cdb512e553b7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 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=${placeholder "out"}"
  ];

  self = (stdenv.mkDerivation ((builtins.removeAttrs attrs [
    "addTclConfigureFlags" "checkPhase" "checkInputs" "doCheck"
  ]) // {

    buildInputs = buildInputs ++ [ tcl.tclPackageHook ];
    nativeBuildInputs = nativeBuildInputs ++ [ makeWrapper 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