biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / coder / default.nix
blobbee71dc2aeae77093e46e862247fea927295c573
1 { lib
2 , channel ? "stable"
3 , fetchurl
4 , installShellFiles
5 , makeBinaryWrapper
6 , terraform
7 , stdenvNoCC
8 , unzip
9 }:
11 let
12   inherit (stdenvNoCC.hostPlatform) system;
14   channels = {
15     stable = {
16       version = "2.9.3";
17       hash = {
18         x86_64-linux = "sha256-6VS21x2egWBV6eJqRCBGG7mEGPIDFtY9GN6Ry4ilC70=";
19         x86_64-darwin = "sha256-UBUGjA+jUkT6p9714l8IvDDI/qhWNctVFOvcA2S5kQU=";
20         aarch64-linux = "sha256-2QAahqcM2gi3lT+18q2Nm9GNqVsqzX3RajBsTn+KB1c=";
21         aarch64-darwin = "sha256-uEH7Y7c9BcU/Q/jwx/inFMvUrgm2dUruID+FJL+rA6Y=";
22       };
23     };
24     mainline = {
25       version = "2.10.1";
26       hash = {
27         x86_64-linux = "sha256-jNPL30e5xvyajlIqivtEpSb3cRhfgFhLFlC+CaLY2IM=";
28         x86_64-darwin = "sha256-U1eQaYwnm/mdQoZ8YxK/+s3HboVfMIAtdI7aQnCiDM8=";
29         aarch64-linux = "sha256-YtSyKZYG8vdubZUfo2FjEoVwSF82TXzeLJjPpHqgFDk=";
30         aarch64-darwin = "sha256-aQSiXK7voP5/mPFIscfTnSc4Ae5/f+WW8MR6ZtuC/eY=";
31       };
32     };
33   };
35 stdenvNoCC.mkDerivation (finalAttrs: {
36   pname = "coder";
37   version = channels.${channel}.version;
38   src = fetchurl {
39     hash = (channels.${channel}.hash).${system};
41     url =
42       let
43         systemName = {
44           x86_64-linux = "linux_amd64";
45           aarch64-linux = "linux_arm64";
46           x86_64-darwin = "darwin_amd64";
47           aarch64-darwin = "darwin_arm64";
48         }.${system};
50         ext = {
51           x86_64-linux = "tar.gz";
52           aarch64-linux = "tar.gz";
53           x86_64-darwin = "zip";
54           aarch64-darwin = "zip";
55         }.${system};
56       in
57       "https://github.com/coder/coder/releases/download/v${finalAttrs.version}/coder_${finalAttrs.version}_${systemName}.${ext}";
58   };
60   nativeBuildInputs = [
61     installShellFiles
62     makeBinaryWrapper
63     unzip
64   ];
66   unpackPhase = ''
67     runHook preUnpack
69     case $src in
70         *.tar.gz) tar -xz -f "$src" ;;
71         *.zip)    unzip      "$src" ;;
72     esac
74     runHook postUnpack
75   '';
77   installPhase = ''
78     runHook preInstall
80     install -D -m755 coder $out/bin/coder
82     runHook postInstall
83   '';
85   postInstall = ''
86     installShellCompletion --cmd coder \
87       --bash <($out/bin/coder completion bash) \
88       --fish <($out/bin/coder completion fish) \
89       --zsh <($out/bin/coder completion zsh)
91     wrapProgram $out/bin/coder \
92       --prefix PATH : ${lib.makeBinPath [ terraform ]}
93   '';
95   # integration tests require network access
96   doCheck = false;
98   meta = {
99     description = "Provision remote development environments via Terraform";
100     homepage = "https://coder.com";
101     license = lib.licenses.agpl3Only;
102     mainProgram = "coder";
103     maintainers = with lib.maintainers; [ ghuntley urandom ];
104   };
106   passthru = {
107     updateScript = ./update.sh;
108   };