2023-02-09 11:40:11 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, gitUpdater
|
2023-04-29 16:46:19 +00:00
|
|
|
, testers
|
2023-02-09 11:40:11 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
, bison
|
|
|
|
, flex
|
|
|
|
, libiconv
|
|
|
|
, libpng
|
|
|
|
, libjpeg
|
|
|
|
, libwebp
|
|
|
|
, zlib
|
|
|
|
, withGUI ? true
|
|
|
|
, qtbase ? null
|
|
|
|
, wrapQtAppsHook ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert withGUI -> qtbase != null && wrapQtAppsHook != null;
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "alice-tools" + lib.optionalString withGUI "-qt${lib.versions.major qtbase.version}";
|
|
|
|
version = "0.13.0";
|
2023-02-09 11:40:11 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nunuhara";
|
|
|
|
repo = "alice-tools";
|
2023-04-29 16:46:19 +00:00
|
|
|
rev = finalAttrs.version;
|
2023-02-09 11:40:11 +00:00
|
|
|
fetchSubmodules = true;
|
2023-04-29 16:46:19 +00:00
|
|
|
hash = "sha256-DazWnBeI5XShkIx41GFZLP3BbE0O8T9uflvKIZUXCHo=";
|
2023-02-09 11:40:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = lib.optionalString (withGUI && lib.versionAtLeast qtbase.version "6.0") ''
|
2023-04-29 16:46:19 +00:00
|
|
|
# Use Meson's Qt6 module
|
2023-02-09 11:40:11 +00:00
|
|
|
substituteInPlace src/meson.build \
|
|
|
|
--replace qt5 qt6
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
# For some reason Meson uses QMake instead of pkg-config detection method for Qt6 on Darwin, which gives wrong search paths for tools
|
|
|
|
export PATH=${qtbase.dev}/libexec:$PATH
|
2023-02-09 11:40:11 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
mesonFlags = lib.optionals (withGUI && lib.versionAtLeast qtbase.version "6.0") [
|
|
|
|
# Qt6 requires at least C++17, project uses compiler's default, default too old on Darwin & aarch64-linux
|
|
|
|
"-Dcpp_std=c++17"
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
bison
|
|
|
|
flex
|
|
|
|
] ++ lib.optionals withGUI [
|
|
|
|
wrapQtAppsHook
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libiconv
|
|
|
|
libpng
|
|
|
|
libjpeg
|
|
|
|
libwebp
|
|
|
|
zlib
|
|
|
|
] ++ lib.optionals withGUI [
|
|
|
|
qtbase
|
|
|
|
];
|
|
|
|
|
|
|
|
dontWrapQtApps = true;
|
|
|
|
|
|
|
|
# Default install step only installs a static library of a build dependency
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
install -Dm755 src/alice $out/bin/alice
|
|
|
|
'' + lib.optionalString withGUI ''
|
|
|
|
install -Dm755 src/galice $out/bin/galice
|
|
|
|
wrapQtApp $out/bin/galice
|
|
|
|
'' + ''
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = gitUpdater { };
|
|
|
|
tests.version = testers.testVersion {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
command = lib.optionalString withGUI "env QT_QPA_PLATFORM=minimal " + "${lib.getExe finalAttrs.finalPackage} --version";
|
|
|
|
};
|
|
|
|
};
|
2023-02-09 11:40:11 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Tools for extracting/editing files from AliceSoft games";
|
|
|
|
homepage = "https://github.com/nunuhara/alice-tools";
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ OPNA2608 ];
|
|
|
|
mainProgram = if withGUI then "galice" else "alice";
|
|
|
|
};
|
2023-04-29 16:46:19 +00:00
|
|
|
})
|