cinnamon-common: Patch {cancel-print-dialog,lpstat-a}.py (#380364)
[NixPkgs.git] / pkgs / by-name / he / heroku / package.nix
blob78a370854af32968a0559d59a5c1f655708a836e
2   stdenv,
3   lib,
4   fetchzip,
5   makeWrapper,
6   nodejs,
7   writeScript,
8 }:
10 stdenv.mkDerivation {
11   pname = "heroku";
12   version = "10.0.2";
14   src = fetchzip {
15     url = "https://cli-assets.heroku.com/versions/10.0.2/7947ef4/heroku-v10.0.2-7947ef4-linux-x64.tar.xz";
16     hash = "sha256-+z+oP4KUhlQuhmvXJ8cxkrDJzllww1gybJCst7RIph0=";
17   };
19   nativeBuildInputs = [ makeWrapper ];
21   dontBuild = true;
23   installPhase = ''
24     mkdir -p $out/share/heroku $out/bin
25     cp -pr * $out/share/heroku
26     substituteInPlace $out/share/heroku/bin/run \
27       --replace "/usr/bin/env node" "${nodejs}/bin/node"
28     makeWrapper $out/share/heroku/bin/run $out/bin/heroku \
29       --set HEROKU_DISABLE_AUTOUPDATE 1
30   '';
32   passthru.updateScript = writeScript "update-heroku" ''
33     #!/usr/bin/env nix-shell
34     #!nix-shell -I nixpkgs=./. -i bash -p nix-prefetch curl jq common-updater-scripts
35     resp="$(
36         curl -L "https://cli-assets.heroku.com/versions/heroku-linux-x64-tar-xz.json" \
37             | jq '[to_entries[] | { version: .key, url: .value } | select(.version|contains("-")|not)] | sort_by(.version|split(".")|map(tonumber)) | .[-1]'
38     )"
39     url="$(jq <<<"$resp" .url --raw-output)"
40     version="$(jq <<<"$resp" .version --raw-output)"
41     hash="$(nix-prefetch fetchzip --url "$(jq <<<"$resp" .url --raw-output)")"
42     update-source-version heroku "$version" "$hash" "$url"
43   '';
45   meta = {
46     homepage = "https://devcenter.heroku.com/articles/heroku-cli";
47     description = "Everything you need to get started using Heroku";
48     mainProgram = "heroku";
49     maintainers = with lib.maintainers; [
50       aflatter
51       mirdhyn
52     ];
53     license = lib.licenses.mit;
54     platforms = with lib.platforms; unix;
55   };