nixpkgs/pkgs/development/libraries/tk/generic.nix
hannesweisbach 371e2622c0
tk: fix build on darwin
Installing libtk on macOS 10.15.5 resulted in a following warning:

    warning: skipping dangling symlink '/nix/store/3whl4256v6qf15dsm1d5mf0lzhfh6w06-user-environment/lib/libtk.so'

which was caused by the following code in generic.nix of the tk derivation:

    ln -s $out/lib/libtk${super.tcl.release}.so $out/lib/libtk.so

Shared libraries on macOS are suffixed `.dylib' not 'so' so
libtk${version}.so does not actually exist. Consequently a symlink from
libtk.dylib is never created and linking against tk fails.
2020-08-15 17:37:13 +02:00

57 lines
1.5 KiB
Nix

{ stdenv, lib, src, pkgconfig, tcl, libXft, patches ? []
, enableAqua ? stdenv.isDarwin, darwin
, ... }:
stdenv.mkDerivation {
name = "tk-${tcl.version}";
inherit src patches;
outputs = [ "out" "man" "dev" ];
setOutputFlags = false;
preConfigure = ''
configureFlagsArray+=(--mandir=$man/share/man --enable-man-symlinks)
cd unix
'';
postInstall = ''
ln -s $out/bin/wish* $out/bin/wish
cp ../{unix,generic}/*.h $out/include
ln -s $out/lib/libtk${tcl.release}${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libtk${stdenv.hostPlatform.extensions.sharedLibrary}
''
+ stdenv.lib.optionalString (stdenv.isDarwin) ''
cp ../macosx/*.h $out/include
'';
configureFlags = [
"--enable-threads"
"--with-tcl=${tcl}/lib"
] ++ stdenv.lib.optional stdenv.is64bit "--enable-64bit"
++ stdenv.lib.optional enableAqua "--enable-aqua";
nativeBuildInputs = [ pkgconfig ];
buildInputs = lib.optional enableAqua (with darwin.apple_sdk.frameworks; [ Cocoa ]);
propagatedBuildInputs = [ tcl libXft ];
doCheck = false; # fails. can't find itself
inherit tcl;
passthru = rec {
inherit (tcl) release version;
libPrefix = "tk${tcl.release}";
libdir = "lib/${libPrefix}";
};
meta = with stdenv.lib; {
description = "A widget toolkit that provides a library of basic elements for building a GUI in many different programming languages";
homepage = "https://www.tcl.tk/";
license = licenses.tcltk;
platforms = platforms.all;
maintainers = with maintainers; [ lovek323 vrthra ];
};
}