2024-08-09 22:37:29 +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-09-26 00:46:28 +00:00
buildPackages ,
2024-08-09 22:37:29 +00:00
at-spi2-atk ,
at-spi2-core ,
libuuid ,
e2fsprogs ,
krb5 ,
libdrm ,
mesa ,
unzip ,
copyDesktopItems ,
libxshmfence ,
libxkbcommon ,
git ,
libGL ,
zlib ,
cacert ,
2017-03-05 15:38:55 +00:00
} :
2018-03-12 17:34:46 +00:00
let
2019-08-15 12:41:18 +00:00
pname = " g i t k r a k e n " ;
2024-11-25 10:04:10 +00:00
version = " 1 0 . 5 . 0 " ;
2017-03-05 15:38:55 +00:00
2021-10-27 01:30:20 +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-01-31 19:23:08 +00:00
2021-10-27 01:30:20 +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-11-25 10:04:10 +00:00
hash = " s h a 2 5 6 - z g z K w Q C t 1 F o B g z V n 1 W r l l A N u B v Y x K j P J N h V q 0 J q i X C M = " ;
2021-10-27 01:30:20 +00:00
} ;
2020-01-31 19:23:08 +00:00
2021-10-27 01:30:20 +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-11-25 10:04:10 +00:00
hash = " s h a 2 5 6 - H 1 r x v C G o 0 m 8 g 5 X S U c u R E M f e + I m / Q s L 6 n s D b P Q D o 0 9 j 4 = " ;
2021-10-27 01:30:20 +00:00
} ;
2017-04-01 21:25:34 +00:00
2022-02-28 20:15:30 +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-11-25 10:04:10 +00:00
hash = " s h a 2 5 6 - O s C b T t G N o + h e Q Q L 6 O E e U q 6 4 D l b s 8 6 F U p f q E J 8 0 P n V 2 o = " ;
2022-02-28 20:15:30 +00:00
} ;
2021-10-27 01:30:20 +00:00
} ;
2017-04-01 21:25:34 +00:00
2021-10-27 01:30:20 +00:00
src = srcs . ${ stdenv . hostPlatform . system } or throwSystem ;
2017-03-05 15:38:55 +00:00
2024-08-13 20:06:15 +00:00
meta = with lib ; {
2024-05-15 21:43:11 +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-04 22:19:25 +00:00
sourceProvenance = with lib . sourceTypes ; [ binaryNativeCode ] ;
2017-03-05 15:38:55 +00:00
license = licenses . unfree ;
2021-10-27 01:30:20 +00:00
platforms = builtins . attrNames srcs ;
2024-08-09 22:37:29 +00:00
maintainers = with maintainers ; [
xnwdd
evanjs
arkivm
nicolas-goudry
] ;
2023-11-27 01:17:53 +00:00
mainProgram = " g i t k r a k e n " ;
2021-10-27 01:30:20 +00:00
} ;
linux = stdenv . mkDerivation rec {
2024-08-09 22:37:29 +00:00
inherit
pname
version
src
meta
;
2021-10-27 01:30:20 +00:00
dontBuild = true ;
dontConfigure = true ;
2024-08-13 20:06:15 +00:00
libPath = lib . makeLibraryPath [
2024-11-07 09:43:39 +00:00
stdenv . cc . cc
2021-10-27 01:30:20 +00:00
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-02-28 20:15:30 +00:00
libxshmfence
libxkbcommon
2023-12-17 10:20:42 +00:00
libGL
zlib
2021-10-27 01:30:20 +00:00
] ;
2024-08-09 22:37:29 +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-10-27 01:30:20 +00:00
2024-08-09 22:37:29 +00:00
nativeBuildInputs = [
copyDesktopItems
2024-09-26 00:46:28 +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-08-09 22:37:29 +00:00
] ;
buildInputs = [
gtk3
adwaita-icon-theme
] ;
2021-10-27 01:30:20 +00:00
2024-02-02 21:11:10 +00:00
# avoid double-wrapping
dontWrapGApps = true ;
2021-10-27 01:30:20 +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
2023-12-17 10:20:42 +00:00
cp gitkraken . png $ out/share/pixmaps /
2021-10-27 01:30:20 +00:00
runHook postInstall
'' ;
2023-08-19 12:04:16 +00:00
preFixup = ''
2024-12-04 18:36:22 +00:00
gappsWrapperArgs + = ( - - add-flags " \' ' ${ NIXOS_OZONE_WL : + \ '' ${ WAYLAND_DISPLAY : + - - ozone-platform-hint = auto - - enable-features = WaylandWindowDecorations - - enable-wayland-ime = true } } " )
2023-08-19 12:04:16 +00:00
'' ;
2021-10-27 01:30:20 +00:00
postFixup = ''
pushd $ out/share / $ { pname }
2023-12-17 10:20:42 +00:00
for file in gitkraken chrome-sandbox chrome_crashpad_handler ; do
2023-01-09 08:07:32 +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-10-27 01:30:20 +00:00
2023-12-17 10:20:42 +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-10-27 01:30:20 +00:00
patchelf - - set-rpath $ { libPath }: $ out/share / $ { pname } $ file || true
done
popd
2023-12-17 10:20:42 +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-02 21:11:10 +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-10-27 01:30:20 +00:00
'' ;
} ;
darwin = stdenv . mkDerivation {
2024-08-09 22:37:29 +00:00
inherit
pname
version
src
meta
;
nativeBuildInputs = [
unzip
makeWrapper
] ;
2021-10-27 01:30:20 +00:00
installPhase = ''
2023-10-24 03:28:10 +00:00
runHook preInstall
2024-06-26 03:08:44 +00:00
mkdir - p $ out/Applications/GitKraken.app $ out/bin
2021-10-27 01:30:20 +00:00
cp - R . $ out/Applications/GitKraken.app
2023-10-24 03:28:10 +00:00
2024-06-26 03:08:44 +00:00
makeWrapper $ out/Applications/GitKraken.app/Contents/MacOS/GitKraken $ out/bin/gitkraken
2023-10-24 03:28:10 +00:00
runHook postInstall
2021-10-27 01:30:20 +00:00
'' ;
2023-10-24 03:28:10 +00:00
dontFixup = true ;
2017-03-05 15:38:55 +00:00
} ;
2021-10-27 01:30:20 +00:00
in
2024-08-09 22:37:29 +00:00
if stdenv . hostPlatform . isDarwin then darwin else linux