Unverified Commit 280a3d43 authored by Francesco Gazzetta's avatar Francesco Gazzetta Committed by GitHub
Browse files

tcl.mkTclDerivation: use extendMkDerivation (#512443)

parents 30d35d0f 1ca3a89b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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/`.
+42 −53
Original line number Diff line number Diff line
# 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 [
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
}