nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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}:
19
20python3Packages.buildPythonApplication rec {
21 pname = "grapejuice";
22 version = "7.8.3";
23
24 src = fetchFromGitLab {
25 owner = "BrinkerVII";
26 repo = "grapejuice";
27 rev = "v${version}";
28 sha256 = "sha256-jNh3L6JDuJryFpHQaP8UesBmepmJopoHxb/XUfOwZz4=";
29 };
30
31 nativeBuildInputs = [
32 gobject-introspection
33 desktop-file-utils
34 glib
35 wrapGAppsHook
36 ];
37
38 buildInputs = [
39 cairo
40 gettext
41 gtk3
42 ];
43
44 propagatedBuildInputs = with python3Packages; [
45 psutil
46 dbus-python
47 pygobject3
48 packaging
49 wheel
50 setuptools
51 requests
52 unidecode
53 click
54 pydantic
55 ];
56
57 dontWrapGApps = true;
58
59 makeWrapperArgs = [
60 "\${gappsWrapperArgs[@]}"
61 "--prefix PATH : ${lib.makeBinPath [ xdg-user-dirs wine winetricks pciutils glxinfo xrandr ]}"
62 # make xdg-open overrideable at runtime
63 "--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}"
64 ];
65
66 postPatch = ''
67 substituteInPlace src/grapejuice_common/assets/desktop/grapejuice.desktop \
68 --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
69 --replace \$GRAPEJUICE_GUI_EXECUTABLE "$out/bin/grapejuice-gui" \
70 --replace \$GRAPEJUICE_ICON grapejuice
71
72 substituteInPlace src/grapejuice_common/assets/desktop/roblox-player.desktop \
73 --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
74 --replace \$PLAYER_ICON "grapejuice-roblox-player"
75
76 substituteInPlace src/grapejuice_common/assets/desktop/roblox-app.desktop \
77 --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
78 --replace \$PLAYER_ICON "grapejuice-roblox-player"
79
80 substituteInPlace src/grapejuice_common/assets/desktop/roblox-studio.desktop \
81 --replace \$GRAPEJUICE_EXECUTABLE "$out/bin/grapejuice" \
82 --replace \$STUDIO_ICON "grapejuice-roblox-studio"
83
84 substituteInPlace src/grapejuice_common/paths.py \
85 --replace 'return local_share() / "locale"' 'return Path("${placeholder "out"}/share/locale")'
86
87 substituteInPlace src/grapejuice_common/models/settings_model.py \
88 --replace 'default_wine_home: Optional[str] = ""' 'default_wine_home: Optional[str] = "${wine}"'
89 '';
90
91 postInstall = ''
92 mkdir -p "$out/share/icons" "$out/share/applications" "$out/share/mime/packages"
93 cp -r src/grapejuice_common/assets/desktop/* $out/share/applications/
94 cp -r src/grapejuice_common/assets/icons $out/share/
95 cp src/grapejuice_common/assets/mime_xml/*.xml $out/share/mime/packages/
96
97 # compile locales (*.po -> *.mo)
98 # from https://gitlab.com/brinkervii/grapejuice/-/blob/master/src/grapejuice_common/util/mo_util.py
99 LOCALE_DIR="$out/share/locale"
100 PO_DIR="src/grapejuice_common/assets/po"
101 LINGUAS_FILE="src/grapejuice_common/assets/po/LINGUAS"
102
103 for lang in $(<"$LINGUAS_FILE") # extract langs from LINGUAS_FILE
104 do
105 po_file="$PO_DIR/$lang.po"
106 mo_file_dir="$LOCALE_DIR/$lang/LC_MESSAGES"
107
108 mkdir -p $mo_file_dir
109
110 mo_file="$mo_file_dir/grapejuice.mo"
111 msgfmt $po_file -o $mo_file # msgfmt from gettext
112 done
113 '';
114
115 # No tests
116 doCheck = false;
117
118 pythonImportsCheck = [ "grapejuice" ];
119
120 meta = with lib; {
121 homepage = "https://gitlab.com/brinkervii/grapejuice";
122 description = "Simple Wine+Roblox management tool";
123 license = licenses.gpl3Plus;
124 platforms = platforms.linux;
125 maintainers = with maintainers; [ artturin helium ];
126 };
127}