biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / misc / inochi2d / generic.nix
blob6666a63ca1ed941b9fbe8a651d5b187f9beed517
2   lib,
3   buildDubPackage,
4   fetchFromGitHub,
5   writeShellScriptBin,
7   cmake,
8   gettext,
9   copyDesktopItems,
10   makeDesktopItem,
11   makeWrapper,
13   dbus,
14   freetype,
15   SDL2,
16   gnome,
18   builderArgs,
21 let
22   cimgui-src = fetchFromGitHub {
23     owner = "Inochi2D";
24     repo = "cimgui";
25     rev = "49bb5ce65f7d5eeab7861d8ffd5aa2a58ca8f08c";
26     hash = "sha256-XcnZbIjwq7vmYBnMAs+cEpJL8HB8wrL098FXGxC+diA=";
27     fetchSubmodules = true;
28   };
30   inherit (builderArgs)
31     pname
32     appname
33     version
34     dubLock
35     meta
36     ;
38 buildDubPackage (
39   builderArgs
40   // {
41     nativeBuildInputs = [
42       cmake # used for building `i2d-imgui`
43       gettext # used when generating translations
44       copyDesktopItems
45       makeWrapper
47       # A fake git implementation to be used by the `gitver` package
48       # It is a dependency of the main packages and the `inochi2d` dub dependency
49       # A side effect of this script is that `inochi2d` will have the same version listed as the main package
50       (writeShellScriptBin "git" "echo v${version}")
51     ];
53     buildInputs = [
54       dbus
55       freetype
56       SDL2
57     ];
59     dontUseCmakeConfigure = true;
61     # these deps are not listed inside `dub.sdl`, so they didn't get auto-generated
62     # these are used for generating version info when building
63     dubLock = lib.recursiveUpdate (lib.importJSON dubLock) {
64       dependencies = {
65         gitver = {
66           version = "1.6.1";
67           sha256 = "sha256-NCyFik4FbD7yMLd5zwf/w4cHwhzLhIRSVw1bWo/CZB4=";
68         };
69         semver = {
70           version = "0.3.2";
71           sha256 = "sha256-l6c9hniUd5xNsJepq8x30e0JTjmXs4pYUmv4ws+Nrn4=";
72         };
73       };
74     };
76     postConfigure = ''
77       cimgui_dir=("$DUB_HOME"/packages/i2d-imgui/*/i2d-imgui)
79       # `i2d-imgui` isn't able to find SDL2 by default due to it being written in lower case
80       # this is only an issue when compiling statically (session)
81       substituteInPlace "$cimgui_dir/dub.json" \
82           --replace-fail '"sdl2"' '"SDL2"'
84       # The `i2d-cimgui` dub dependency fetched inside the auto-generated `*-deps.nix` file
85       # which doesn't know that it's actually a git repo, so it doesn't fetch its submodules.
86       # Upstream uses a cmake script to fetch the `cimgui` submodule anyway, which we can't do
87       # We get around this by manually pre-fetching the submodule and copying it into the right place
88       cp -r --no-preserve=all ${cimgui-src}/* "$cimgui_dir/deps/cimgui"
90       # Disable the original cmake fetcher script
91       substituteInPlace "$cimgui_dir/deps/CMakeLists.txt" \
92           --replace-fail "PullSubmodules(" "# PullSubmodules(" \
93           --replace-fail  "\''${cimgui_SUBMOD_DIR}" "cimgui"
94     '';
96     preBuild = ''
97       # Generate translations (if possible)
98       . gentl.sh
100       # Use the fake git to generate version info
101       dub build --skip-registry=all --compiler=ldc2 --build=release --config=meta
102     '';
104     # Use the "barebones" configuration so that we don't include the mascot and icon files in out build
105     dubFlags = [ "--config=barebones" ];
107     installPhase = ''
108       runHook preInstall
110       mkdir -p $out/share/${pname}
111       cp -r out/* $out/share/${pname}
113       runHook postInstall
114     '';
116     desktopItems = [
117       (makeDesktopItem {
118         name = pname;
119         desktopName = appname;
120         exec = pname;
121         comment = meta.description;
122         categories = [ "Utility" ];
123       })
124     ];
126     postFixup = ''
127       # Add support for `open file` dialog
128       makeWrapper $out/share/${pname}/${pname} $out/bin/${pname} \
129           --prefix PATH : ${lib.makeBinPath [ gnome.zenity ]}
130     '';
132     meta = {
133       homepage = "https://inochi2d.com/";
134       license = lib.licenses.bsd2;
135       mainProgram = pname;
136       maintainers = with lib.maintainers; [ tomasajt ];
137     } // meta;
138   }