biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / networking / instant-messengers / cinny-desktop / default.nix
blob841df5a4cd610668bc095bec8bb2b7b76de8b5cd
1 { lib
2 , stdenv
3 , darwin
4 , fetchFromGitHub
5 , rust
6 , rustPlatform
7 , cargo-tauri
8 , cinny
9 , copyDesktopItems
10 , wrapGAppsHook
11 , pkg-config
12 , openssl
13 , dbus
14 , glib
15 , glib-networking
16 , libayatana-appindicator
17 , webkitgtk
18 , makeDesktopItem
21 rustPlatform.buildRustPackage rec {
22   pname = "cinny-desktop";
23   # We have to be using the same version as cinny-web or this isn't going to work.
24   version = "3.1.0";
26   src = fetchFromGitHub {
27     owner = "cinnyapp";
28     repo = "cinny-desktop";
29     rev = "v${version}";
30     hash = "sha256-v5D0/EHVQ2xo7TGo+jZoRDBVFczkaZu2ka6QpwV4dpw=";
31   };
33   sourceRoot = "${src.name}/src-tauri";
35   # modififying $cargoDepsCopy requires the lock to be vendored
36   cargoLock.lockFile = ./Cargo.lock;
38   postPatch = let
39     cinny' =
40       assert lib.assertMsg (cinny.version == version) "cinny.version (${cinny.version}) != cinny-desktop.version (${version})";
41       cinny;
42   in ''
43     substituteInPlace tauri.conf.json \
44       --replace '"distDir": "../cinny/dist",' '"distDir": "${cinny'}",'
45     substituteInPlace tauri.conf.json \
46       --replace '"cd cinny && npm run build"' '""'
47   '' + lib.optionalString stdenv.hostPlatform.isLinux ''
48     substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \
49       --replace "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
50   '';
52   postBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
53     cargo tauri build --bundles app --target "${rust.envVars.rustHostPlatform}"
54   '';
56   postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
57     install -DT icons/128x128@2x.png $out/share/icons/hicolor/256x256@2/apps/cinny.png
58     install -DT icons/128x128.png $out/share/icons/hicolor/128x128/apps/cinny.png
59     install -DT icons/32x32.png $out/share/icons/hicolor/32x32/apps/cinny.png
60   '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
61     mkdir -p "$out/Applications/"
62     cp -r "target/${rust.envVars.rustHostPlatform}/release/bundle/macos/Cinny.app" "$out/Applications/"
63     ln -sf "$out/Applications/Cinny.app/Contents/MacOS/Cinny" "$out/bin/cinny"
64   '';
66   nativeBuildInputs = [
67     copyDesktopItems
68     wrapGAppsHook
69     pkg-config
70     cargo-tauri
71   ];
73   buildInputs = [
74     openssl
75     dbus
76     glib
77   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
78     glib-networking
79     libayatana-appindicator
80     webkitgtk
81   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
82     darwin.DarwinTools
83     darwin.apple_sdk.frameworks.WebKit
84   ];
86   desktopItems = lib.optionals stdenv.hostPlatform.isLinux [
87     (makeDesktopItem {
88       name = "cinny";
89       exec = "cinny";
90       icon = "cinny";
91       desktopName = "Cinny";
92       comment = meta.description;
93       categories = [ "Network" "InstantMessaging" ];
94     })
95   ];
97   meta = with lib; {
98     description = "Yet another matrix client for desktop";
99     homepage = "https://github.com/cinnyapp/cinny-desktop";
100     maintainers = with maintainers; [ qyriad ];
101     license = licenses.agpl3Only;
102     platforms = platforms.linux ++ platforms.darwin;
103     mainProgram = "cinny";
104   };