Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tclPackages: init #344716

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,15 @@
- pkgs/os-specific/linux/systemd/**/*
- nixos/modules/system/boot/systemd*/**/*

"6.topic: tcl":
- any:
- changed-files:
- any-glob-to-any-file:
- doc/languages-frameworks/tcl.section.md
- pkgs/development/interpreters/tcl/*
- pkgs/development/tcl-modules/**/*
- pkgs/top-level/tcl-packages.nix

"6.topic: TeX":
- any:
- changed-files:
Expand Down
7 changes: 7 additions & 0 deletions ci/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ nixos/modules/installer/tools/nix-fallback-paths.nix @NixOS/nix-team @raitobeza
/pkgs/build-support/rust @zowoq @winterqt @figsoda
/doc/languages-frameworks/rust.section.md @zowoq @winterqt @figsoda

# Tcl
/pkgs/development/interpreters/tcl @fgaz
/pkgs/development/libraries/tk @fgaz
/pkgs/top-level/tcl-packages.nix @fgaz
/pkgs/development/tcl-modules @fgaz
/doc/languages-frameworks/tcl.section.md @fgaz

# C compilers
/pkgs/development/compilers/gcc
/pkgs/development/compilers/llvm @alyssais @RossComputerGuy @NixOS/llvm
Expand Down
1 change: 1 addition & 0 deletions doc/languages-frameworks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ ruby.section.md
rust.section.md
scheme.section.md
swift.section.md
tcl.section.md
texlive.section.md
titanium.section.md
vim.section.md
Expand Down
54 changes: 54 additions & 0 deletions doc/languages-frameworks/tcl.section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Tcl {#sec-language-tcl}

## User guide {#sec-language-tcl-user-guide}

Tcl interpreters are available under the `tcl` and `tcl-X_Y` attributes, where `X_Y` is the Tcl version.

Tcl libraries are available in the `tclPackages` attribute set.
They are only guaranteed to work with the default Tcl version, but will probably also work with others thanks to the [stubs mechanism](https://wiki.tcl-lang.org/page/Stubs).

## Packaging guide {#sec-language-tcl-packaging}

Tcl packages are typically built with `tclPackages.mkTclDerivation`.
Tcl dependencies go in `buildInputs`/`nativeBuildInputs`/... like other packages.
For more complex package definitions, such as packages with mixed languages, use `tcl.tclPackageHook`.

Where possible, make sure to enable stubs for maximum compatibility, usually with the `--enable-stubs` configure flag.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not default to this in mkTclDerivation and make an option to disable it for the few things that don't support it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually plan to do this in a later PR so this one stays at 0 actual rebuilds


Here is a simple package example to be called with `tclPackages.callPackage`.

```
{ lib, fetchzip, mkTclDerivation, openssl }:

mkTclDerivation rec {
pname = "tcltls";
version = "1.7.22";

src = fetchzip {
url = "https://core.tcl-lang.org/tcltls/uv/tcltls-${version}.tar.gz";
hash = "sha256-TOouWcQc3MNyJtaAGUGbaQoaCWVe6g3BPERct/V65vk=";
};

buildInputs = [ openssl ];

configureFlags = [
"--with-ssl-dir=${openssl.dev}"
"--enable-stubs"
];

meta = {
homepage = "https://core.tcl-lang.org/tcltls/index";
description = "OpenSSL / RSA-bsafe Tcl extension";
maintainers = [ lib.maintainers.agbrooks ];
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/`.
If possible, prefer the by-name hierarchy in `pkgs/development/tcl-modules/by-name/`.
Its use is documented in `pkgs/development/tcl-modules/by-name/README.md`.

All Tcl applications reside elsewhere.
In case a package is used as both a library and an application (for example `expect`), it should be defined in `tcl-packages.nix`, with an alias elsewhere.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@
`nodePackages.coc-eslint` and `vimPlugins.coc-eslint` packages offer comparable
features for `eslint`, which replaced `tslint`.

- Tcl packages have been moved into the `tclPackages` scope.

- `teleport` has been upgraded from major version 15 to major version 16.
Refer to upstream [upgrade instructions](https://goteleport.com/docs/management/operations/upgrading/)
and [release notes for v16](https://goteleport.com/docs/changelog/#1600-061324).
Expand Down
10 changes: 4 additions & 6 deletions pkgs/applications/misc/therion/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
, pkg-config
, perl
, tcl
, tcllib
, tclPackages
, tk
, expat
, bwidget
, python3
, texliveTeTeX
, survex
Expand All @@ -25,7 +24,6 @@
, sqlite
, libtiff
, curl
, tkimg
}:

stdenv.mkDerivation rec {
Expand Down Expand Up @@ -59,7 +57,7 @@ stdenv.mkDerivation rec {

buildInputs = [
expat
tkimg
tclPackages.tkimg
proj
wxGTK32
vtk
Expand All @@ -74,8 +72,8 @@ stdenv.mkDerivation rec {
curl
fmt
tcl
tcllib
bwidget
tclPackages.tcllib
tclPackages.bwidget
];

fixupPhase = ''
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/science/electronics/openroad/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
, readline
, spdlog
, tcl
, tcllib
, tclPackages
, xorg
, yosys
, zlib
Expand Down Expand Up @@ -72,7 +72,7 @@ mkDerivation rec {
readline
spdlog
tcl
tcllib
tclPackages.tcllib
yosys
xorg.libX11
zlib
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/version-management/fossil/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
, sqlite
, ed
, which
, tcllib
, tclPackages
, withJson ? true
}:

Expand All @@ -28,7 +28,7 @@ stdenv.mkDerivation (finalAttrs: {
# required for build time tool `./tools/translate.c`
depsBuildBuild = [ buildPackages.stdenv.cc ];

nativeBuildInputs = [ installShellFiles tcl tcllib ];
nativeBuildInputs = [ installShellFiles tcl tclPackages.tcllib ];

buildInputs = [ zlib openssl readline which ed ]
++ lib.optional stdenv.hostPlatform.isDarwin libiconv
Expand Down
6 changes: 3 additions & 3 deletions pkgs/by-name/em/emacspeak/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
, makeWrapper
, stdenv
, tcl
, tclx
, tclPackages
}:

stdenv.mkDerivation (finalAttrs: {
Expand All @@ -27,7 +27,7 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [
espeak-ng
tcl
tclx
tclPackages.tclx
];

strictDeps = true;
Expand All @@ -49,7 +49,7 @@ stdenv.mkDerivation (finalAttrs: {
find "$d" -type f -not -executable -execdir chmod 644 {} +
makeWrapper ${lib.getExe emacs} $out/bin/emacspeak \
--set DTK_PROGRAM "${placeholder "out"}/share/emacs/site-lisp/emacspeak/servers/espeak" \
--set TCLLIBPATH "${tclx}/lib" \
--set TCLLIBPATH "${tclPackages.tclx}/lib" \
--add-flags '-l "${placeholder "out"}/share/emacs/site-lisp/emacspeak/lisp/emacspeak-setup.elc"'
'';

Expand Down
15 changes: 9 additions & 6 deletions pkgs/by-name/ke/keydb/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
jemalloc,
which,
tcl,
tcltls,
tclPackages,
ps,
getconf,
nixosTests,
Expand Down Expand Up @@ -60,11 +60,14 @@ stdenv.mkDerivation (finalAttrs: {

# darwin currently lacks a pure `pgrep` which is extensively used here
doCheck = !stdenv.hostPlatform.isDarwin;
nativeCheckInputs = [
which
tcl
ps
] ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ] ++ lib.optionals tlsSupport [ tcltls ];
nativeCheckInputs =
[
which
tcl
ps
]
++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ]
++ lib.optionals tlsSupport [ tclPackages.tcltls ];
checkPhase = ''
runHook preCheck

Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/re/remind/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
stdenv,
fetchurl,
tk,
tcllib,
tclPackages,
tcl,
tkremind ? null,
withGui ?
Expand All @@ -23,7 +23,7 @@ tcl.mkTclDerivation rec {
};

propagatedBuildInputs = lib.optionals withGui [
tcllib
tclPackages.tcllib
tk
];

Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/xf/xfs-undelete/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
, makeWrapper
, coreutils
, tcl-8_6
, tcllib
, tclPackages
, installShellFiles
}:

Expand All @@ -19,7 +19,7 @@ stdenv.mkDerivation {
hash = "sha256-ENa/r3+o7abW8iun6V/2LhTVmFVSwVM6v46KXBcKJ1g=";
};

buildInputs = [ tcl-8_6 tcllib coreutils ];
buildInputs = [ tcl-8_6 tclPackages.tcllib coreutils ];
nativeBuildInputs = [ makeWrapper tcl-8_6.tclPackageHook installShellFiles ];

tclWrapperArgs = [ "--prefix" "PATH" ":" (lib.makeBinPath [ tcl-8_6 ]) ];
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/interpreters/python/cpython/2.7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
, openssl
, readline
, sqlite
, tcl ? null, tk ? null, tix ? null, libX11 ? null, x11Support ? false
, tcl ? null, tk ? null, tclPackages, libX11 ? null, x11Support ? false
, zlib
, self
, configd, coreutils
Expand Down Expand Up @@ -273,8 +273,8 @@ in with passthru; stdenv.mkDerivation ({

setupHook = python-setup-hook sitePackages;

postPatch = lib.optionalString (x11Support && (tix != null)) ''
substituteInPlace "Lib/lib-tk/Tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
postPatch = lib.optionalString (x11Support && ((tclPackages.tix or null) != null)) ''
substituteInPlace "Lib/lib-tk/Tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'"
'';

postInstall =
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/interpreters/python/cpython/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
, tzdata
, withGdbm ? !stdenv.hostPlatform.isWindows, gdbm
, withReadline ? !stdenv.hostPlatform.isWindows, readline
, x11Support ? false, tcl, tk, tix, libX11, xorgproto
, x11Support ? false, tcl, tk, tclPackages, libX11, xorgproto

# splicing/cross
, pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}"
Expand Down Expand Up @@ -323,10 +323,10 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
'' + optionalString mimetypesSupport ''
substituteInPlace Lib/mimetypes.py \
--replace-fail "@mime-types@" "${mailcap}"
'' + optionalString (pythonOlder "3.13" && x11Support && (tix != null)) ''
'' + optionalString (pythonOlder "3.13" && x11Support && ((tclPackages.tix or null) != null)) ''
substituteInPlace "Lib/tkinter/tix.py" --replace-fail \
"os.environ.get('TIX_LIBRARY')" \
"os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
"os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'"
'';

env = {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/interpreters/python/pypy/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib, stdenv, substituteAll, fetchurl
, zlibSupport ? true, zlib
, bzip2, pkg-config, libffi, libunwind, Security
, sqlite, openssl, ncurses, python, expat, tcl, tk, tix, libX11
, sqlite, openssl, ncurses, python, expat, tcl, tk, tclPackages, libX11
, gdbm, db, xz, python-setup-hook
, optimizationLevel ? "jit", boehmgc
# For the Python package set
Expand Down Expand Up @@ -98,7 +98,7 @@ in with passthru; stdenv.mkDerivation rec {
--replace "multiprocessing.cpu_count()" "$NIX_BUILD_CORES"

substituteInPlace "lib-python/${if isPy3k then "3/tkinter/tix.py" else "2.7/lib-tk/Tix.py"}" \
--replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
--replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'"
'';

buildPhase = ''
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/r-modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ let
RMySQL = with pkgs; [ zlib libmysqlclient openssl.dev ];
RNetCDF = with pkgs; [ netcdf udunits ];
RODBC = [ pkgs.libiodbc ];
rpanel = [ pkgs.bwidget ];
rpanel = [ pkgs.tclPackages.bwidget ];
Rpoppler = [ pkgs.poppler ];
RPostgres = with pkgs; [ postgresql ];
RPostgreSQL = with pkgs; [ postgresql postgresql ];
Expand Down Expand Up @@ -1460,9 +1460,9 @@ let

rpanel = old.rpanel.overrideAttrs (attrs: {
preConfigure = ''
export TCLLIBPATH="${pkgs.bwidget}/lib/bwidget${pkgs.bwidget.version}"
export TCLLIBPATH="${pkgs.tclPackages.bwidget}/lib/bwidget${pkgs.tclPackages.bwidget.version}"
'';
TCLLIBPATH = "${pkgs.bwidget}/lib/bwidget${pkgs.bwidget.version}";
TCLLIBPATH = "${pkgs.tclPackages.bwidget}/lib/bwidget${pkgs.tclPackages.bwidget.version}";
});

networkscaleup = old.networkscaleup.overrideAttrs (attrs: {
Expand Down
17 changes: 17 additions & 0 deletions pkgs/development/tcl-modules/by-name/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Name-based Tcl package directories

The structure of this directory is identical to the one described in
[/pkgs/by-name/README.md](../../../by-name/README.md).
The only difference is the scope:

```nix
{ lib
# You can get tclPackages attributes directly
, mkTclDerivation
, tcllib
}:

mkTclDerivation {
# ...
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, fetchurl, tcl, tk }:
{ lib, fetchurl, mkTclDerivation, tk }:

tcl.mkTclDerivation rec {
mkTclDerivation rec {
pname = "bwidget";
version = "1.10.0";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, stdenv, fetchurl, writeText, tcl }:
{ lib, stdenv, mkTclDerivation, fetchurl, writeText, tcl }:

tcl.mkTclDerivation rec {
mkTclDerivation rec {
pname = "incrtcl";
version = "4.2.3";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, stdenv, fetchurl, tcl, tk, incrtcl }:
{ lib, stdenv, fetchurl, mkTclDerivation, tk, incrtcl }:

tcl.mkTclDerivation rec {
mkTclDerivation rec {
pname = "itk-tcl";
version = "4.1.0";

Expand Down
Loading