at 24.11-pre 2.7 kB view raw
1{ lib 2, channel ? "stable" 3, fetchurl 4, installShellFiles 5, makeBinaryWrapper 6, terraform 7, stdenvNoCC 8, unzip 9}: 10 11let 12 inherit (stdenvNoCC.hostPlatform) system; 13 14 channels = { 15 stable = { 16 version = "2.10.2"; 17 hash = { 18 x86_64-linux = "sha256-U3qHEjIKq8JkpDp6TehMs6t5L3GpSGt4D10XSAQ9Ii0="; 19 x86_64-darwin = "sha256-ibfqqxRRD3IfIN2FqSxk5qd7d87RvBgKKFv9F0hACgo="; 20 aarch64-linux = "sha256-HdBVnLKen6W1crZfnc2hpA0cAYIYeYFHKvANwnLqkjY="; 21 aarch64-darwin = "sha256-3sHmR6PTRlBSIdD4rja4y8v0gOY4cbbyhW7qssgpqp8="; 22 }; 23 }; 24 mainline = { 25 version = "2.11.0"; 26 hash = { 27 x86_64-linux = "sha256-aJwL4WCJXxSBrfaUHEECQqedz2lKBOa8sdRItSBpxp4="; 28 x86_64-darwin = "sha256-4D4MoDrEJtawFeUBG9BiJ6HZ9uqx9uQDIHHNB7m2pp8="; 29 aarch64-linux = "sha256-2UlCxykSfnK50OPb61YC42MTTlPL1njf0vpwmqaUbI8="; 30 aarch64-darwin = "sha256-mh0Lr+SH4jZTx1xH7QoqfSLDma5nS61sv31QuOYAgQk="; 31 }; 32 }; 33 }; 34in 35stdenvNoCC.mkDerivation (finalAttrs: { 36 pname = "coder"; 37 version = channels.${channel}.version; 38 src = fetchurl { 39 hash = (channels.${channel}.hash).${system}; 40 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}; 49 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 }; 59 60 nativeBuildInputs = [ 61 installShellFiles 62 makeBinaryWrapper 63 unzip 64 ]; 65 66 unpackPhase = '' 67 runHook preUnpack 68 69 case $src in 70 *.tar.gz) tar -xz -f "$src" ;; 71 *.zip) unzip "$src" ;; 72 esac 73 74 runHook postUnpack 75 ''; 76 77 installPhase = '' 78 runHook preInstall 79 80 install -D -m755 coder $out/bin/coder 81 82 runHook postInstall 83 ''; 84 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) 90 91 wrapProgram $out/bin/coder \ 92 --prefix PATH : ${lib.makeBinPath [ terraform ]} 93 ''; 94 95 # integration tests require network access 96 doCheck = false; 97 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 kylecarbs urandom ]; 104 }; 105 106 passthru = { 107 updateScript = ./update.sh; 108 }; 109})