aboutsummaryrefslogtreecommitdiff
path: root/modules/pkgs/open-goal-launcher.nix
blob: 99c0f5bea892653dc162ae44031fd35c07f8d383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
{ inputs, ... }:
{
  perSystem =
    { system, ... }:
    let
      pkgs = import inputs.nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
    in
    {
      packages.open-goal-launcher = pkgs.callPackage (
        {
          cairo,
          cmake,
          copyDesktopItems,
          fetchFromGitHub,
          fetchYarnDeps,
          glib,
          glib-networking,
          gtk3,
          lib,
          libayatana-appindicator,
          librsvg,
          libsoup_3,
          makeDesktopItem,
          nodejs,
          openssl,
          pango,
          pkg-config,
          rustPlatform,
          stdenv,
          webkitgtk_4_1,
          wrapGAppsHook3,
          yarn,
          yarnConfigHook,
        }:
        let
          version = "2.10.4";

          src = fetchFromGitHub {
            owner = "open-goal";
            repo = "launcher";
            rev = "v${version}";
            hash = "sha256-8ceTadkf1E4uTrxkLj131KoBf34GuIiku1CCqyLwbwU=";
          };

          desktopItem = makeDesktopItem {
            name = "open-goal-launcher";
            desktopName = "OpenGOAL Launcher";
            genericName = "OpenGOAL Launcher";
            comment = "Install and manage OpenGOAL game releases";
            exec = "open-goal-launcher";
            icon = "open-goal-launcher";
            terminal = false;
            categories = [
              "Game"
              "Utility"
            ];
          };
        in
        rustPlatform.buildRustPackage {
          pname = "open-goal-launcher";
          inherit version src;

          strictDeps = true;

          cargoRoot = "src-tauri";
          buildAndTestSubdir = "src-tauri";

          cargoLock = {
            lockFile = "${src}/src-tauri/Cargo.lock";
          };

          offlineCache = fetchYarnDeps {
            yarnLock = "${src}/yarn.lock";
            hash = "sha256-be8jhKeVkomrYFjYu/cM21mCDRRysjbtUUW9+MWB4Fo=";
          };

          desktopItems = [ desktopItem ];

          nativeBuildInputs = [
            cmake
            copyDesktopItems
            nodejs
            pkg-config
            wrapGAppsHook3
            yarn
            yarnConfigHook
          ];

          buildInputs = [
            cairo
            glib
            glib-networking
            gtk3
            libayatana-appindicator
            librsvg
            libsoup_3
            openssl
            pango
            webkitgtk_4_1
          ];

          env.OPENSSL_NO_VENDOR = "1";

          preBuild = ''
            pushd "$NIX_BUILD_TOP/$sourceRoot"
            yarn --offline build
            popd
          '';

          doCheck = false;

          installPhase = ''
            runHook preInstall

            root="$NIX_BUILD_TOP/$sourceRoot"

            launcher="$(
              find "$root/target" \
                -type f \
                -path "*/release/opengoal-launcher" \
                -perm -0100 \
                -print \
                -quit
            )"

            if [ -z "$launcher" ]; then
              echo "Could not find the compiled OpenGOAL Launcher executable"
              find "$root/target" -maxdepth 4 -type f -print
              exit 1
            fi

            install -Dm755 \
              "$launcher" \
              "$out/bin/open-goal-launcher"

            install -Dm644 \
              "$root/src-tauri/icons/32x32.png" \
              "$out/share/icons/hicolor/32x32/apps/open-goal-launcher.png"

            install -Dm644 \
              "$root/src-tauri/icons/128x128.png" \
              "$out/share/icons/hicolor/128x128/apps/open-goal-launcher.png"

            install -Dm644 \
              "$root/src-tauri/icons/128x128@2x.png" \
              "$out/share/icons/hicolor/256x256/apps/open-goal-launcher.png"

            runHook postInstall
          '';

          preFixup = ''
            gappsWrapperArgs+=(
              --set WEBKIT_DISABLE_DMABUF_RENDERER 1
            )
          '';

          meta = {
            description = "Launcher for installing and managing OpenGOAL releases";
            homepage = "https://github.com/open-goal/launcher";
            license = lib.licenses.isc;
            mainProgram = "open-goal-launcher";
            platforms = [ "x86_64-linux" ];
          };
        }
      ) { };
    };

  flake.modules.nixos.open-goal-launcher =
    { pkgs, ... }:
    {
      environment.systemPackages = [
        inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.open-goal-launcher
      ];
    };

  flake.modules.homeManager.open-goal-launcher =
    { pkgs, ... }:
    {
      home.packages = [
        inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.open-goal-launcher
      ];
    };
}