2024-09-19 14:19:46 +00:00
{
lib ,
stdenv ,
libXcomposite ,
libgnome-keyring ,
makeWrapper ,
udev ,
curlWithGnuTls ,
alsa-lib ,
libXfixes ,
atk ,
gtk3 ,
libXrender ,
pango ,
adwaita-icon-theme ,
cairo ,
freetype ,
fontconfig ,
libX11 ,
libXi ,
libxcb ,
libXext ,
libXcursor ,
glib ,
libXScrnSaver ,
libxkbfile ,
libXtst ,
nss ,
nspr ,
cups ,
fetchzip ,
expat ,
gdk-pixbuf ,
libXdamage ,
libXrandr ,
dbus ,
makeDesktopItem ,
openssl ,
wrapGAppsHook3 ,
2024-10-04 16:56:33 +00:00
buildPackages ,
2024-09-19 14:19:46 +00:00
at-spi2-atk ,
at-spi2-core ,
libuuid ,
e2fsprogs ,
krb5 ,
libdrm ,
mesa ,
unzip ,
copyDesktopItems ,
libxshmfence ,
libxkbcommon ,
git ,
libGL ,
zlib ,
cacert ,
2020-04-24 23:36:52 +00:00
} :
let
pname = " g i t k r a k e n " ;
2024-10-04 16:56:33 +00:00
version = " 1 0 . 4 . 0 " ;
2020-04-24 23:36:52 +00:00
2021-12-06 16:07:01 +00:00
throwSystem = throw " U n s u p p o r t e d s y s t e m : ${ stdenv . hostPlatform . system } " ;
2020-04-24 23:36:52 +00:00
2021-12-06 16:07:01 +00:00
srcs = {
x86_64-linux = fetchzip {
url = " h t t p s : / / r e l e a s e . a x o c d n . c o m / l i n u x / G i t K r a k e n - v ${ version } . t a r . g z " ;
2024-10-04 16:56:33 +00:00
hash = " s h a 2 5 6 - J G W D O A k J E n h v U y Q O F s m o e W 9 I z j 0 I u H N p Y G l Y A M i W P j 0 = " ;
2021-12-06 16:07:01 +00:00
} ;
2020-04-24 23:36:52 +00:00
2021-12-06 16:07:01 +00:00
x86_64-darwin = fetchzip {
url = " h t t p s : / / r e l e a s e . a x o c d n . c o m / d a r w i n / G i t K r a k e n - v ${ version } . z i p " ;
2024-10-04 16:56:33 +00:00
hash = " s h a 2 5 6 - y C D E 6 Q J M g U 2 M g r / k U D n b K w Q 3 M p g V c d j A K 7 f n T A j S L 5 4 = " ;
2021-12-06 16:07:01 +00:00
} ;
2020-04-24 23:36:52 +00:00
2022-03-10 19:12:11 +00:00
aarch64-darwin = fetchzip {
url = " h t t p s : / / r e l e a s e . a x o c d n . c o m / d a r w i n - a r m 6 4 / G i t K r a k e n - v ${ version } . z i p " ;
2024-10-04 16:56:33 +00:00
hash = " s h a 2 5 6 - n h + t O + + Q v P x 9 j y Z u x N r H 7 r H F X Z q V n u 5 j y i k i 3 o W d w 7 E = " ;
2022-03-10 19:12:11 +00:00
} ;
2021-12-06 16:07:01 +00:00
} ;
2020-04-24 23:36:52 +00:00
2021-12-06 16:07:01 +00:00
src = srcs . ${ stdenv . hostPlatform . system } or throwSystem ;
2020-04-24 23:36:52 +00:00
2024-09-19 14:19:46 +00:00
meta = with lib ; {
2024-06-05 15:53:02 +00:00
homepage = " h t t p s : / / w w w . g i t k r a k e n . c o m / g i t - c l i e n t " ;
description = " S i m p l i f y i n g G i t f o r a n y O S " ;
2022-06-26 10:26:21 +00:00
sourceProvenance = with lib . sourceTypes ; [ binaryNativeCode ] ;
2020-04-24 23:36:52 +00:00
license = licenses . unfree ;
2021-12-06 16:07:01 +00:00
platforms = builtins . attrNames srcs ;
2024-09-19 14:19:46 +00:00
maintainers = with maintainers ; [
xnwdd
evanjs
arkivm
nicolas-goudry
] ;
2024-01-02 11:29:13 +00:00
mainProgram = " g i t k r a k e n " ;
2021-12-06 16:07:01 +00:00
} ;
linux = stdenv . mkDerivation rec {
2024-09-19 14:19:46 +00:00
inherit
pname
version
src
meta
;
2021-12-06 16:07:01 +00:00
dontBuild = true ;
dontConfigure = true ;
2024-09-19 14:19:46 +00:00
libPath = lib . makeLibraryPath [
2021-12-06 16:07:01 +00:00
stdenv . cc . cc . lib
curlWithGnuTls
udev
libX11
libXext
libXcursor
libXi
libxcb
glib
libXScrnSaver
libxkbfile
libXtst
nss
nspr
cups
alsa-lib
expat
gdk-pixbuf
dbus
libXdamage
libXrandr
atk
pango
cairo
freetype
fontconfig
libXcomposite
libXfixes
libXrender
gtk3
libgnome-keyring
openssl
at-spi2-atk
at-spi2-core
libuuid
e2fsprogs
krb5
libdrm
mesa
2022-03-10 19:12:11 +00:00
libxshmfence
libxkbcommon
2024-01-25 14:12:00 +00:00
libGL
zlib
2021-12-06 16:07:01 +00:00
] ;
2024-09-19 14:19:46 +00:00
desktopItems = [
( makeDesktopItem {
name = " G i t K r a k e n D e s k t o p " ;
exec = " g i t k r a k e n " ;
icon = " g i t k r a k e n " ;
desktopName = " G i t K r a k e n D e s k t o p " ;
genericName = " G i t C l i e n t " ;
categories = [ " D e v e l o p m e n t " ] ;
comment = " U n l e a s h y o u r r e p o " ;
} )
] ;
2021-12-06 16:07:01 +00:00
2024-09-19 14:19:46 +00:00
nativeBuildInputs = [
copyDesktopItems
2024-10-04 16:56:33 +00:00
# override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651
# 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.
( buildPackages . wrapGAppsHook3 . override { makeWrapper = buildPackages . makeShellWrapper ; } )
2024-09-19 14:19:46 +00:00
] ;
buildInputs = [
gtk3
adwaita-icon-theme
] ;
2021-12-06 16:07:01 +00:00
2024-02-07 01:22:34 +00:00
# avoid double-wrapping
dontWrapGApps = true ;
2021-12-06 16:07:01 +00:00
installPhase = ''
runHook preInstall
mkdir - p $ out/share / $ { pname } /
cp - R $ src /* $ o u t / s h a r e / $ { p n a m e }
mkdir - p $ out/share/pixmaps
2024-01-25 14:12:00 +00:00
cp gitkraken . png $ out/share/pixmaps /
2021-12-06 16:07:01 +00:00
runHook postInstall
'' ;
2024-04-21 15:54:59 +00:00
preFixup = ''
gappsWrapperArgs + = ( - - add-flags " \' ' ${ NIXOS_OZONE_WL : + \ '' ${ WAYLAND_DISPLAY : + - - ozone-platform-hint = auto - - enable-features = WaylandWindowDecorations } } " )
'' ;
2021-12-06 16:07:01 +00:00
postFixup = ''
pushd $ out/share / $ { pname }
2024-01-25 14:12:00 +00:00
for file in gitkraken chrome-sandbox chrome_crashpad_handler ; do
2023-02-02 18:25:31 +00:00
patchelf - - set-interpreter " $ ( c a t $ N I X _ C C / n i x - s u p p o r t / d y n a m i c - l i n k e r ) " $ file
done
2021-12-06 16:07:01 +00:00
2024-01-25 14:12:00 +00:00
for file in $ ( find . - type f \ ( - name \ * . node - o - name gitkraken - o - name git - o - name git- \ * - o - name scalar - o - name \ * . so \ * \ ) ) ; do
2021-12-06 16:07:01 +00:00
patchelf - - set-rpath $ { libPath }: $ out/share / $ { pname } $ file || true
done
popd
2024-01-25 14:12:00 +00:00
# SSL and permissions fix for bundled nodegit
pushd $ out/share / $ { pname } /resources/app.asar.unpacked/node_modules / @ axosoft/nodegit/build/Release
mv nodegit-ubuntu-18 . node nodegit-ubuntu-18-ssl-1 .1 .1 . node
mv nodegit-ubuntu-18-ssl-static . node nodegit-ubuntu-18 . node
chmod 755 nodegit-ubuntu-18 . node
popd
# Devendor bundled git
rm - rf $ out/share / $ { pname } /resources/app.asar.unpacked/git
ln - s $ { git } $ out/share / $ { pname } /resources/app.asar.unpacked/git
# GitKraken expects the CA bundle to be located in the bundled git directory. Since we replace it with
# the one from nixpkgs, which doesn't provide a CA bundle, we need to explicitly set its location at runtime
2024-02-07 01:22:34 +00:00
makeWrapper $ out/share / $ { pname } /gitkraken $ out/bin/gitkraken \
- - set GIT_SSL_CAINFO " ${ cacert } / e t c / s s l / c e r t s / c a - b u n d l e . c r t " \
" ' ' ${ gappsWrapperArgs [ @ ] } "
2021-12-06 16:07:01 +00:00
'' ;
} ;
darwin = stdenv . mkDerivation {
2024-09-19 14:19:46 +00:00
inherit
pname
version
src
meta
;
nativeBuildInputs = [
unzip
makeWrapper
] ;
2021-12-06 16:07:01 +00:00
installPhase = ''
2023-11-16 04:20:00 +00:00
runHook preInstall
2024-07-01 15:47:52 +00:00
mkdir - p $ out/Applications/GitKraken.app $ out/bin
2021-12-06 16:07:01 +00:00
cp - R . $ out/Applications/GitKraken.app
2023-11-16 04:20:00 +00:00
2024-07-01 15:47:52 +00:00
makeWrapper $ out/Applications/GitKraken.app/Contents/MacOS/GitKraken $ out/bin/gitkraken
2023-11-16 04:20:00 +00:00
runHook postInstall
2021-12-06 16:07:01 +00:00
'' ;
2023-11-16 04:20:00 +00:00
dontFixup = true ;
2020-04-24 23:36:52 +00:00
} ;
2021-12-06 16:07:01 +00:00
in
2024-09-26 11:04:55 +00:00
if stdenv . hostPlatform . isDarwin then darwin else linux