Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 107 lines 2.5 kB view raw
1{ 2 stdenv, 3 lib, 4 gitUpdater, 5 testers, 6 fetchFromGitHub, 7 meson, 8 ninja, 9 pkg-config, 10 bison, 11 flex, 12 libiconv, 13 libpng, 14 libjpeg, 15 libwebp, 16 zlib, 17 withGUI ? true, 18 qtbase ? null, 19 wrapQtAppsHook ? null, 20}: 21 22assert withGUI -> qtbase != null && wrapQtAppsHook != null; 23 24stdenv.mkDerivation (finalAttrs: { 25 pname = "alice-tools" + lib.optionalString withGUI "-qt${lib.versions.major qtbase.version}"; 26 version = "0.13.0"; 27 28 src = fetchFromGitHub { 29 owner = "nunuhara"; 30 repo = "alice-tools"; 31 rev = finalAttrs.version; 32 fetchSubmodules = true; 33 hash = "sha256-DazWnBeI5XShkIx41GFZLP3BbE0O8T9uflvKIZUXCHo="; 34 }; 35 36 postPatch = lib.optionalString (withGUI && lib.versionAtLeast qtbase.version "6.0") '' 37 # Use Meson's Qt6 module 38 substituteInPlace src/meson.build \ 39 --replace qt5 qt6 40 41 # For some reason Meson uses QMake instead of pkg-config detection method for Qt6 on Darwin, which gives wrong search paths for tools 42 export PATH=${qtbase.dev}/libexec:$PATH 43 ''; 44 45 mesonFlags = lib.optionals (withGUI && lib.versionAtLeast qtbase.version "6.0") [ 46 # Qt6 requires at least C++17, project uses compiler's default, default too old on Darwin & aarch64-linux 47 "-Dcpp_std=c++17" 48 ]; 49 50 nativeBuildInputs = [ 51 meson 52 ninja 53 pkg-config 54 bison 55 flex 56 ] 57 ++ lib.optionals withGUI [ 58 wrapQtAppsHook 59 ]; 60 61 buildInputs = [ 62 libiconv 63 libpng 64 libjpeg 65 libwebp 66 zlib 67 ] 68 ++ lib.optionals withGUI [ 69 qtbase 70 ]; 71 72 dontWrapQtApps = true; 73 74 # Default install step only installs a static library of a build dependency 75 installPhase = '' 76 runHook preInstall 77 78 install -Dm755 src/alice $out/bin/alice 79 '' 80 + lib.optionalString withGUI '' 81 install -Dm755 src/galice $out/bin/galice 82 wrapQtApp $out/bin/galice 83 '' 84 + '' 85 86 runHook postInstall 87 ''; 88 89 passthru = { 90 updateScript = gitUpdater { }; 91 tests.version = testers.testVersion { 92 package = finalAttrs.finalPackage; 93 command = 94 lib.optionalString withGUI "env QT_QPA_PLATFORM=minimal " 95 + "${lib.getExe finalAttrs.finalPackage} --version"; 96 }; 97 }; 98 99 meta = with lib; { 100 description = "Tools for extracting/editing files from AliceSoft games"; 101 homepage = "https://github.com/nunuhara/alice-tools"; 102 license = licenses.gpl2Plus; 103 platforms = platforms.all; 104 maintainers = with maintainers; [ OPNA2608 ]; 105 mainProgram = if withGUI then "galice" else "alice"; 106 }; 107})