1{
2 stdenvNoCC,
3 lib,
4 fetchurl,
5 autoPatchelfHook,
6 buildPackages,
7 gnome-keyring,
8 libsecret,
9 git,
10 curl,
11 nss,
12 nspr,
13 xorg,
14 libdrm,
15 alsa-lib,
16 cups,
17 libgbm,
18 systemd,
19 openssl,
20 libglvnd,
21}:
22
23let
24 rcversion = "1";
25in
26stdenvNoCC.mkDerivation (finalAttrs: {
27 pname = "github-desktop";
28 version = "3.4.13";
29
30 src =
31 let
32 urls = {
33 "x86_64-linux" = {
34 url = "https://github.com/shiftkey/desktop/releases/download/release-${finalAttrs.version}-linux${rcversion}/GitHubDesktop-linux-amd64-${finalAttrs.version}-linux${rcversion}.deb";
35 hash = "sha256-i1V3dhx5AMrCiWtfvB2I9a6ki2zncUNyYr4qZqs42Yc=";
36 };
37 "aarch64-linux" = {
38 url = "https://github.com/shiftkey/desktop/releases/download/release-${finalAttrs.version}-linux${rcversion}/GitHubDesktop-linux-arm64-${finalAttrs.version}-linux${rcversion}.deb";
39 hash = "sha256-SN4qtEI4q/AAgfUaBiM5eWyCK5Kr77CrTHsIAmvEceU=";
40 };
41 };
42 in
43 fetchurl
44 urls."${stdenvNoCC.hostPlatform.system}"
45 or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
46
47 nativeBuildInputs = [
48 autoPatchelfHook
49 # override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651
50 # Has to use `makeShellWrapper` from `buildPackages` even though `makeShellWrapper` from the inputs is spliced because `propagatedBuildInputs` would pick the wrong one because of a different offset.
51 (buildPackages.wrapGAppsHook3.override { makeWrapper = buildPackages.makeShellWrapper; })
52 ];
53
54 buildInputs = [
55 gnome-keyring
56 xorg.libXdamage
57 xorg.libX11
58 libsecret
59 git
60 curl
61 nss
62 nspr
63 libdrm
64 alsa-lib
65 cups
66 libgbm
67 openssl
68 ];
69
70 unpackPhase = ''
71 runHook preUnpack
72 mkdir -p $TMP/github-desktop $out/{opt,bin}
73 cp $src $TMP/github-desktop.deb
74 ar vx github-desktop.deb
75 tar --no-overwrite-dir -xvf data.tar.xz -C $TMP/github-desktop/
76 runHook postUnpack
77 '';
78
79 installPhase = ''
80 runHook preInstall
81 cp -R $TMP/github-desktop/usr/share $out/
82 cp -R $TMP/github-desktop/usr/lib/github-desktop/* $out/opt/
83 ln -sf $out/opt/github-desktop $out/bin/github-desktop
84 runHook postInstall
85 '';
86
87 preFixup = ''
88 gappsWrapperArgs+=(
89 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland --enable-wayland-ime=true}}"
90 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libglvnd ]}
91 )
92 '';
93
94 runtimeDependencies = [
95 (lib.getLib systemd)
96 ];
97
98 meta = {
99 description = "GUI for managing Git and GitHub";
100 homepage = "https://desktop.github.com/";
101 license = lib.licenses.mit;
102 mainProgram = "github-desktop";
103 maintainers = with lib.maintainers; [ ];
104 platforms = lib.platforms.linux;
105 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
106 };
107})