nixos/wyoming/{faster-whisper,piper}: drop download directory (#376447)
[NixPkgs.git] / pkgs / by-name / ti / tideways-cli / package.nix
blob074a12d49d0096513cc4c479567030f779fd34e5
2   stdenvNoCC,
3   lib,
4   fetchurl,
5   curl,
6   common-updater-scripts,
7   writeShellApplication,
8   gnugrep,
9   installShellFiles,
12 stdenvNoCC.mkDerivation (finalAttrs: {
13   pname = "tideways-cli";
14   version = "1.2.4";
16   nativeBuildInputs = [ installShellFiles ];
18   src =
19     finalAttrs.passthru.sources.${stdenvNoCC.hostPlatform.system}
20       or (throw "Unsupported platform for tideways-cli: ${stdenvNoCC.hostPlatform.system}");
22   installPhase = ''
23     runHook preInstall
25     mkdir -p $out/bin
26     cp tideways $out/bin/tideways
27     chmod +x $out/bin/tideways
29     installShellCompletion --cmd tideways \
30       --bash <($out/bin/tideways completion bash) \
31       --zsh <($out/bin/tideways completion zsh) \
32       --fish <($out/bin/tideways completion fish)
34     runHook postInstall
35   '';
37   passthru = {
38     sources = {
39       "x86_64-linux" = fetchurl {
40         url = "https://s3-eu-west-1.amazonaws.com/tideways/cli/${finalAttrs.version}/tideways-cli_linux_amd64-${finalAttrs.version}.tar.gz";
41         hash = "sha256-PoZHmr4kq6A6aTVlo9kbjnRSkLBJ9q/GneHGWoEvraQ=";
42       };
43       "aarch64-linux" = fetchurl {
44         url = "https://s3-eu-west-1.amazonaws.com/tideways/cli/${finalAttrs.version}/tideways-cli_linux_arm64-${finalAttrs.version}.tar.gz";
45         hash = "sha256-8r3s9izpi8fR+lSDQ6ZAxGWK2XQxrtp7WgRykRC+pD4=";
46       };
47       "x86_64-darwin" = fetchurl {
48         url = "https://s3-eu-west-1.amazonaws.com/tideways/cli/${finalAttrs.version}/tideways-cli_macos_amd64-${finalAttrs.version}.tar.gz";
49         hash = "sha256-D40PF6zgf79NO1K35koZ2gpUeJllF9CpW9DoCQ1uJIU=";
50       };
51       "aarch64-darwin" = fetchurl {
52         url = "https://s3-eu-west-1.amazonaws.com/tideways/cli/${finalAttrs.version}/tideways-cli_macos_arm64-${finalAttrs.version}.tar.gz";
53         hash = "sha256-QGkRu0IRUpydLIy0DgtRhLiH0mLZ0UTRCJo1WZeICQQ=";
54       };
55     };
57     updateScript = "${
58       writeShellApplication {
59         name = "update-tideways-cli";
60         runtimeInputs = [
61           curl
62           gnugrep
63           common-updater-scripts
64         ];
65         text = ''
66           NEW_VERSION=$(curl --fail -L -s https://tideways.com/profiler/downloads | grep -E 'https://tideways.s3.amazonaws.com/cli/([0-9]+\.[0-9]+\.[0-9]+)/tideways-cli_linux_amd64-\1.tar.gz' | grep -oP 'cli/\K[0-9]+\.[0-9]+\.[0-9]+')
68           if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
69               echo "The new version same as the old version."
70               exit 0
71           fi
73           for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
74             update-source-version "tideways-cli" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
75           done
76         '';
77       }
78     }/bin/update-tideways-cli";
79   };
81   meta = with lib; {
82     description = "Tideways Profiler CLI";
83     homepage = "https://tideways.com/";
84     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
85     mainProgram = "tideways";
86     license = licenses.unfree;
87     maintainers = with maintainers; [ shyim ];
88     platforms = lib.attrNames finalAttrs.passthru.sources;
89   };