Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 version, 3 rev, 4 sha256, 5}: 6 7{ 8 stdenv, 9 lib, 10 fetchFromGitHub, 11 cmake, 12 pkg-config, 13 zlib, 14 libjpeg, 15 libpng, 16 fontconfig, 17 freetype, 18 libX11, 19 libXext, 20 libXinerama, 21 libXfixes, 22 libXcursor, 23 libXft, 24 libXrender, 25 26 withGL ? true, 27 libGL, 28 libGLU, 29 glew, 30 31 withCairo ? true, 32 cairo, 33 34 withPango ? (lib.strings.versionAtLeast version "1.4" && stdenv.hostPlatform.isLinux), 35 pango, 36 37 withDocs ? true, 38 doxygen, 39 graphviz, 40 41 withExamples ? (stdenv.buildPlatform == stdenv.hostPlatform), 42 withShared ? true, 43}: 44 45let 46 onOff = value: if value then "ON" else "OFF"; 47in 48stdenv.mkDerivation { 49 pname = "fltk"; 50 inherit version; 51 52 src = fetchFromGitHub { 53 owner = "fltk"; 54 repo = "fltk"; 55 inherit rev sha256; 56 }; 57 58 outputs = [ "out" ] ++ lib.optional withExamples "bin" ++ lib.optional withDocs "doc"; 59 60 # Manually move example & test binaries to $bin to avoid cyclic dependencies on dev binaries 61 outputBin = lib.optionalString withExamples "out"; 62 63 patches = lib.optionals stdenv.hostPlatform.isDarwin [ 64 ./nsosv.patch 65 ]; 66 67 postPatch = '' 68 patchShebangs documentation/make_* 69 ''; 70 71 nativeBuildInputs = [ 72 cmake 73 pkg-config 74 ] 75 ++ lib.optionals withDocs [ 76 doxygen 77 graphviz 78 ]; 79 80 buildInputs = 81 lib.optionals (withGL && !stdenv.hostPlatform.isDarwin) [ 82 libGL 83 libGLU 84 ] 85 ++ lib.optionals (withExamples && withGL) [ 86 glew 87 ] 88 ++ lib.optionals stdenv.hostPlatform.isLinux [ 89 fontconfig 90 ]; 91 92 propagatedBuildInputs = [ 93 zlib 94 libjpeg 95 libpng 96 ] 97 ++ lib.optionals stdenv.hostPlatform.isLinux [ 98 freetype 99 libX11 100 libXext 101 libXinerama 102 libXfixes 103 libXcursor 104 libXft 105 libXrender 106 ] 107 ++ lib.optionals withCairo [ 108 cairo 109 ] 110 ++ lib.optionals withPango [ 111 pango 112 ]; 113 114 cmakeFlags = [ 115 # Common 116 "-DOPTION_BUILD_SHARED_LIBS=${onOff withShared}" 117 "-DOPTION_USE_SYSTEM_ZLIB=ON" 118 "-DOPTION_USE_SYSTEM_LIBJPEG=ON" 119 "-DOPTION_USE_SYSTEM_LIBPNG=ON" 120 121 # X11 122 "-DOPTION_USE_XINERAMA=${onOff stdenv.hostPlatform.isLinux}" 123 "-DOPTION_USE_XFIXES=${onOff stdenv.hostPlatform.isLinux}" 124 "-DOPTION_USE_XCURSOR=${onOff stdenv.hostPlatform.isLinux}" 125 "-DOPTION_USE_XFT=${onOff stdenv.hostPlatform.isLinux}" 126 "-DOPTION_USE_XRENDER=${onOff stdenv.hostPlatform.isLinux}" 127 "-DOPTION_USE_XDBE=${onOff stdenv.hostPlatform.isLinux}" 128 129 # GL 130 "-DOPTION_USE_GL=${onOff withGL}" 131 "-DOpenGL_GL_PREFERENCE=GLVND" 132 133 # Cairo 134 "-DOPTION_CAIRO=${onOff withCairo}" 135 "-DOPTION_CAIROEXT=${onOff withCairo}" 136 137 # Pango 138 "-DOPTION_USE_PANGO=${onOff withPango}" 139 140 # Examples & Tests 141 "-DFLTK_BUILD_EXAMPLES=${onOff withExamples}" 142 "-DFLTK_BUILD_TEST=${onOff withExamples}" 143 144 # Docs 145 "-DOPTION_BUILD_HTML_DOCUMENTATION=${onOff withDocs}" 146 "-DOPTION_BUILD_PDF_DOCUMENTATION=OFF" 147 "-DOPTION_INSTALL_HTML_DOCUMENTATION=${onOff withDocs}" 148 "-DOPTION_INSTALL_PDF_DOCUMENTATION=OFF" 149 "-DOPTION_INCLUDE_DRIVER_DOCUMENTATION=${onOff withDocs}" 150 151 # RPATH of binary /nix/store/.../bin/... contains a forbidden reference to /build/ 152 "-DCMAKE_SKIP_BUILD_RPATH=ON" 153 ]; 154 155 preBuild = lib.optionalString (withCairo && withShared && stdenv.hostPlatform.isDarwin) '' 156 # unresolved symbols in cairo dylib without this: https://github.com/fltk/fltk/issues/250 157 export NIX_LDFLAGS="$NIX_LDFLAGS -undefined dynamic_lookup" 158 ''; 159 160 postBuild = lib.optionalString withDocs '' 161 make docs 162 ''; 163 164 postInstall = 165 lib.optionalString withExamples '' 166 mkdir -p $bin/bin 167 mv bin/{test,examples}/* $bin/bin/ 168 '' 169 + lib.optionalString stdenv.hostPlatform.isDarwin '' 170 mkdir -p $out/Library/Frameworks 171 mv $out{,/Library/Frameworks}/FLTK.framework 172 173 moveAppBundles() { 174 echo "Moving and symlinking $1" 175 appname="$(basename "$1")" 176 binname="$(basename "$(find "$1"/Contents/MacOS/ -type f -executable | head -n1)")" 177 curpath="$(dirname "$1")" 178 179 mkdir -p "$curpath"/../Applications/ 180 mv "$1" "$curpath"/../Applications/ 181 [ -f "$curpath"/"$binname" ] && rm "$curpath"/"$binname" 182 ln -s ../Applications/"$appname"/Contents/MacOS/"$binname" "$curpath"/"$binname" 183 } 184 185 rm $out/bin/fluid.icns 186 for app in $out/bin/*.app ${lib.optionalString withExamples "$bin/bin/*.app"}; do 187 moveAppBundles "$app" 188 done 189 ''; 190 191 postFixup = '' 192 substituteInPlace $out/bin/fltk-config \ 193 --replace "/$out/" "/" 194 ''; 195 196 meta = with lib; { 197 description = "C++ cross-platform lightweight GUI library"; 198 homepage = "https://www.fltk.org"; 199 platforms = platforms.unix; 200 # LGPL2 with static linking exception 201 # https://www.fltk.org/COPYING.php 202 license = licenses.lgpl2Only; 203 }; 204}