Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 src, 5 pkg-config, 6 tcl, 7 libXft, 8 zip, 9 zlib, 10 patches ? [ ], 11 enableAqua ? stdenv.hostPlatform.isDarwin, 12 ... 13}: 14 15tcl.mkTclDerivation { 16 pname = "tk"; 17 version = tcl.version; 18 19 inherit src patches; 20 21 outputs = [ 22 "out" 23 "man" 24 "dev" 25 ]; 26 27 setOutputFlags = false; 28 29 preConfigure = '' 30 configureFlagsArray+=(--mandir=$man/share/man --enable-man-symlinks) 31 cd unix 32 ''; 33 34 postPatch = '' 35 for file in $(find library/demos/. -type f ! -name "*.*"); do 36 substituteInPlace $file --replace "exec wish" "exec $out/bin/wish" 37 done 38 ''; 39 40 postInstall = 41 let 42 # From version 9, the tcl version is included in the lib filename 43 libtclstring = lib.optionalString (lib.versionAtLeast tcl.version "9.0") "tcl${lib.versions.major tcl.version}"; 44 libfile = "$out/lib/lib${libtclstring}tk${tcl.release}${stdenv.hostPlatform.extensions.sharedLibrary}"; 45 in 46 '' 47 ln -s $out/bin/wish* $out/bin/wish 48 cp ../{unix,generic}/*.h $out/include 49 ln -s ${libfile} $out/lib/libtk${stdenv.hostPlatform.extensions.sharedLibrary} 50 '' 51 + lib.optionalString (stdenv.hostPlatform.isDarwin) '' 52 cp ../macosx/*.h $out/include 53 ''; 54 55 configureFlags = [ 56 "--enable-threads" 57 ] 58 ++ lib.optional stdenv.hostPlatform.is64bit "--enable-64bit" 59 ++ lib.optional enableAqua "--enable-aqua" 60 ++ 61 lib.optional (lib.versionAtLeast tcl.version "9.0") 62 # By default, tk libraries get zipped and embedded into libtcl9tk*.so, 63 # which gets `zipfs mount`ed at runtime. This is fragile (for example 64 # stripping the .so removes the zip trailer), so we install them as 65 # traditional files. 66 # This might make tcl slower to start from slower storage on cold cache, 67 # however according to my benchmarks on fast storage and warm cache 68 # tcl built with --disable-zipfs actually starts in half the time. 69 "--disable-zipfs"; 70 71 nativeBuildInputs = [ 72 pkg-config 73 ] 74 ++ lib.optionals (lib.versionAtLeast tcl.version "9.0") [ 75 # Only used to detect the presence of zlib. Could be replaced with a stub. 76 zip 77 ]; 78 buildInputs = lib.optionals (lib.versionAtLeast tcl.version "9.0") [ 79 zlib 80 ]; 81 82 propagatedBuildInputs = [ 83 libXft 84 ]; 85 86 enableParallelBuilding = true; 87 88 doCheck = false; # fails. can't find itself 89 90 inherit tcl; 91 92 passthru = rec { 93 inherit (tcl) release version; 94 libPrefix = "tk${tcl.release}"; 95 libdir = "lib/${libPrefix}"; 96 }; 97 98 meta = with lib; { 99 description = "Widget toolkit that provides a library of basic elements for building a GUI in many different programming languages"; 100 homepage = "https://www.tcl.tk/"; 101 license = licenses.tcltk; 102 platforms = platforms.all; 103 maintainers = [ ]; 104 broken = stdenv.hostPlatform.isDarwin && lib.elem (lib.versions.majorMinor tcl.version) [ "8.5" ]; 105 }; 106}