Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / blockchains / trezor-suite / default.nix
blobe5f8963e921c66ea85fd87665f690dbfb45eecb5
1 { lib
2 , stdenv
3 , fetchurl
4 , appimageTools
5 , tor
6 , trezord
7 }:
9 let
10   pname = "trezor-suite";
11   version = "23.10.1";
12   name = "${pname}-${version}";
14   suffix = {
15     aarch64-linux = "linux-arm64";
16     x86_64-linux  = "linux-x86_64";
17   }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
19   src = fetchurl {
20     url = "https://github.com/trezor/${pname}/releases/download/v${version}/Trezor-Suite-${version}-${suffix}.AppImage";
21     hash = { # curl -Lfs https://github.com/trezor/trezor-suite/releases/latest/download/latest-linux{-arm64,}.yml | grep ^sha512 | sed 's/: /-/'
22       aarch64-linux = "sha512-MR9BYg6R+Oof3zh02KSh48V2m6J7JpsrYpi6gj5kTvKuCU5Ci5AwPEAvnTjHAR6xlappvoNQmeA5nCEoTWaL7A==";
23       x86_64-linux  = "sha512-BqdfhYLG4z+9B7KbJGWGPml7U2fl/RQ1nZK0vdeA/cKhG0SjH0K8er9bemg60RPBXj0AeuK80v/6vMbDtyEnRQ==";
24     }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
25   };
27   appimageContents = appimageTools.extractType2 {
28     inherit name src;
29   };
33 appimageTools.wrapType2 rec {
34   inherit name src;
36   extraInstallCommands = ''
37     mv $out/bin/${name} $out/bin/${pname}
38     mkdir -p $out/bin $out/share/${pname} $out/share/${pname}/resources
40     cp -a ${appimageContents}/locales/ $out/share/${pname}
41     cp -a ${appimageContents}/resources/app*.* $out/share/${pname}/resources
42     cp -a ${appimageContents}/resources/images/ $out/share/${pname}/resources
44     install -m 444 -D ${appimageContents}/${pname}.desktop $out/share/applications/${pname}.desktop
45     install -m 444 -D ${appimageContents}/resources/images/desktop/512x512.png $out/share/icons/hicolor/512x512/apps/${pname}.png
46     substituteInPlace $out/share/applications/${pname}.desktop \
47       --replace 'Exec=AppRun --no-sandbox %U' 'Exec=${pname}'
49     # symlink system binaries instead bundled ones
50     mkdir -p $out/share/${pname}/resources/bin/{bridge,tor}
51     ln -sf ${trezord}/bin/trezord-go $out/share/${pname}/resources/bin/bridge/trezord
52     ln -sf ${tor}/bin/tor $out/share/${pname}/resources/bin/tor/tor
53   '';
55   meta = with lib; {
56     description = "Trezor Suite - Desktop App for managing crypto";
57     homepage = "https://suite.trezor.io";
58     changelog = "https://github.com/trezor/trezor-suite/releases/tag/v${version}";
59     license = licenses.unfree;
60     maintainers = with maintainers; [ prusnak ];
61     platforms = [ "aarch64-linux" "x86_64-linux" ];
62   };