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