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