Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / games / grapejuice / default.nix
blobc8d1956eb9a546e9b367a546422e6690d53d8097
1 { lib
2 , fetchFromGitLab
3 , gobject-introspection
4 , pciutils
5 , python3Packages
6 , gtk3
7 , wrapGAppsHook
8 , glib
9 , cairo
10 , desktop-file-utils
11 , xdg-utils
12 , xdg-user-dirs
13 , gettext
14 , winetricks
15 , wine
16 , glxinfo
17 , xrandr
18 , bash
21 python3Packages.buildPythonApplication rec  {
22   pname = "grapejuice";
23   version = "7.20.11";
25   src = fetchFromGitLab {
26     owner = "BrinkerVII";
27     repo = "grapejuice";
28     rev = "v${version}";
29     hash = "sha256-sDw67Xseeak1v5x0daznfdeNQahDTj21AVvXmuZlsgg=";
30   };
32   nativeBuildInputs = [
33     gobject-introspection
34     desktop-file-utils
35     glib
36     wrapGAppsHook
37     python3Packages.pip
38   ];
40   buildInputs = [
41     cairo
42     gettext
43     gtk3
44     bash
45   ];
47   propagatedBuildInputs = with python3Packages; [
48     psutil
49     dbus-python
50     pygobject3
51     packaging
52     wheel
53     setuptools
54     requests
55     unidecode
56     click
57     pydantic
58   ];
60   dontWrapGApps = true;
62   makeWrapperArgs = [
63     "--prefix PATH : ${lib.makeBinPath [ xdg-user-dirs wine winetricks pciutils glxinfo xrandr ]}"
64     # make xdg-open overrideable at runtime
65     "--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}"
66   ];
68   postPatch = ''
69     substituteInPlace src/grapejuice_common/assets/desktop/grapejuice.desktop \
70       --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
71       --replace \$GRAPEJUICE_GUI_EXECUTABLE "$out/bin/grapejuice-gui" \
72       --replace \$GRAPEJUICE_ICON grapejuice
74     substituteInPlace src/grapejuice_common/assets/desktop/roblox-player.desktop \
75       --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
76       --replace \$PLAYER_ICON "grapejuice-roblox-player"
78     substituteInPlace src/grapejuice_common/assets/desktop/roblox-app.desktop \
79       --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
80       --replace \$PLAYER_ICON "grapejuice-roblox-player"
82     substituteInPlace src/grapejuice_common/assets/desktop/roblox-studio.desktop src/grapejuice_common/assets/desktop/roblox-studio-auth.desktop \
83       --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
84       --replace \$STUDIO_ICON "grapejuice-roblox-studio"
86     substituteInPlace src/grapejuice_common/paths.py \
87       --replace 'return local_share() / "locale"' 'return Path("${placeholder "out"}/share/locale")'
89     substituteInPlace src/grapejuice_common/models/settings_model.py \
90       --replace 'default_wine_home: Optional[str] = ""' 'default_wine_home: Optional[str] = "${wine}"'
92     substituteInPlace src/grapejuice_packaging/builders/linux_package_builder.py \
93       --replace '"--no-dependencies",' '"--no-dependencies", "--no-build-isolation",'
95     substituteInPlace src/grapejuice_packaging/packaging_resources/bin/grapejuice src/grapejuice_packaging/packaging_resources/bin/grapejuice-gui \
96       --replace "/usr/bin/env python3" "${python3Packages.python.interpreter}"
97   '';
99   installPhase = ''
100     runHook preInstall
102     PYTHONPATH=$(pwd)/src:$PYTHONPATH python3 -m grapejuice_packaging linux_package
104     mkdir -p "$out" "$out/${python3Packages.python.sitePackages}"
105     tar -xvf ./dist/linux_package/grapejuice-''${version}.tar.gz --strip-components=1 -C "$out"
107     mv "$out/lib/python3/dist-packages/"* "$out/${python3Packages.python.sitePackages}"
108     rmdir --ignore-fail-on-non-empty -p "$out/lib/python3/dist-packages"
110     runHook postInstall
111   '';
113   postFixup = ''
114     patchShebangs "$out/bin/grapejuice{,-gui}"
116     buildPythonPath "$out $pythonPath"
118     for bin in grapejuice grapejuice-gui; do
119     wrapProgram "$out/bin/$bin" \
120       --prefix PYTHONPATH : "$PYTHONPATH:$(toPythonPath $out)" \
121       ''${makeWrapperArgs[@]} \
122       ''${gappsWrapperArgs[@]}
123     done
124   '';
126   # No tests
127   doCheck = false;
129   pythonImportsCheck = [ "grapejuice" ];
131   meta = with lib; {
132     homepage = "https://gitlab.com/brinkervii/grapejuice";
133     description = "Simple Wine+Roblox management tool";
134     license = licenses.gpl3Plus;
135     platforms = platforms.linux;
136     maintainers = with maintainers; [ artturin helium ];
137   };