Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 autoPatchelfHook,
3 squashfsTools,
4 alsa-lib,
5 fetchurl,
6 makeDesktopItem,
7 makeWrapper,
8 stdenv,
9 lib,
10 libsecret,
11 libgbm,
12 udev,
13 wrapGAppsHook3,
14 writeScript,
15}:
16
17stdenv.mkDerivation rec {
18 pname = "termius";
19 version = "9.26.0";
20 revision = "232";
21
22 src = fetchurl {
23 # find the latest version with
24 # curl -H 'X-Ubuntu-Series: 16' https://api.snapcraft.io/api/v1/snaps/details/termius-app | jq '.version'
25 # and the url with
26 # curl -H 'X-Ubuntu-Series: 16' https://api.snapcraft.io/api/v1/snaps/details/termius-app | jq '.download_url' -r
27 # and the sha512 with
28 # curl -H 'X-Ubuntu-Series: 16' https://api.snapcraft.io/api/v1/snaps/details/termius-app | jq '.download_sha512' -r
29 url = "https://api.snapcraft.io/api/v1/snaps/download/WkTBXwoX81rBe3s3OTt3EiiLKBx2QhuS_${revision}.snap";
30 hash = "sha512-PBwZS1CcvGFfodM3bqM/YWDJxoF/thZvTWIIPQI1ShjVWbvJUq29J/xeaNyncgQCfowgR8xWIOVpmAjCjjyQ0A==";
31 };
32
33 desktopItem = makeDesktopItem {
34 categories = [ "Network" ];
35 comment = "The SSH client that works on Desktop and Mobile";
36 desktopName = "Termius";
37 exec = "termius-app";
38 genericName = "Cross-platform SSH client";
39 icon = "termius-app";
40 name = "termius-app";
41 };
42
43 dontBuild = true;
44 dontConfigure = true;
45 dontPatchELF = true;
46 dontWrapGApps = true;
47
48 # TODO: migrate off autoPatchelfHook and use nixpkgs' electron
49 nativeBuildInputs = [
50 autoPatchelfHook
51 squashfsTools
52 makeWrapper
53 wrapGAppsHook3
54 ];
55
56 buildInputs = [
57 alsa-lib
58 libsecret
59 libgbm
60 ];
61
62 unpackPhase = ''
63 runHook preUnpack
64 unsquashfs "$src"
65 runHook postUnpack
66 '';
67
68 installPhase = ''
69 runHook preInstall
70 cd squashfs-root
71 mkdir -p $out/opt/termius
72 cp -r ./ $out/opt/termius
73
74 mkdir -p "$out/share/applications" "$out/share/pixmaps"
75 cp "${desktopItem}/share/applications/"* "$out/share/applications"
76 cp meta/gui/icon.png $out/share/pixmaps/termius-app.png
77
78 runHook postInstall
79 '';
80
81 runtimeDependencies = [ (lib.getLib udev) ];
82
83 postFixup = ''
84 makeWrapper $out/opt/termius/termius-app $out/bin/termius-app \
85 "''${gappsWrapperArgs[@]}"
86 '';
87
88 passthru.updateScript = writeScript "update-termius" ''
89 #!/usr/bin/env nix-shell
90 #!nix-shell -i bash -p common-updater-scripts curl jq
91
92 set -eu -o pipefail
93
94 data=$(curl -H 'X-Ubuntu-Series: 16' \
95 'https://api.snapcraft.io/api/v1/snaps/details/termius-app?fields=download_sha512,revision,version')
96
97 version=$(jq -r .version <<<"$data")
98
99 if [[ "x$UPDATE_NIX_OLD_VERSION" != "x$version" ]]; then
100
101 revision=$(jq -r .revision <<<"$data")
102 hash=$(nix --extra-experimental-features nix-command hash to-sri "sha512:$(jq -r .download_sha512 <<<"$data")")
103
104 update-source-version "$UPDATE_NIX_ATTR_PATH" "$version" "$hash"
105 update-source-version --ignore-same-hash --version-key=revision "$UPDATE_NIX_ATTR_PATH" "$revision" "$hash"
106
107 fi
108 '';
109
110 meta = with lib; {
111 description = "Cross-platform SSH client with cloud data sync and more";
112 homepage = "https://termius.com/";
113 downloadPage = "https://termius.com/linux/";
114 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
115 license = licenses.unfree;
116 maintainers = with maintainers; [
117 Br1ght0ne
118 th0rgal
119 Rishik-Y
120 ];
121 platforms = [ "x86_64-linux" ];
122 mainProgram = "termius-app";
123 };
124}