2023-03-15 16:39:30 +00:00
|
|
|
{ lib
|
2024-04-21 15:54:59 +00:00
|
|
|
, channel ? "stable"
|
|
|
|
, fetchurl
|
2022-11-21 17:40:18 +00:00
|
|
|
, installShellFiles
|
2024-04-21 15:54:59 +00:00
|
|
|
, makeBinaryWrapper
|
2023-03-15 16:39:30 +00:00
|
|
|
, terraform
|
2024-04-21 15:54:59 +00:00
|
|
|
, stdenvNoCC
|
|
|
|
, unzip
|
2022-11-21 17:40:18 +00:00
|
|
|
}:
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
let
|
|
|
|
inherit (stdenvNoCC.hostPlatform) system;
|
|
|
|
|
|
|
|
channels = {
|
|
|
|
stable = {
|
|
|
|
version = "2.9.3";
|
|
|
|
hash = {
|
|
|
|
x86_64-linux = "sha256-6VS21x2egWBV6eJqRCBGG7mEGPIDFtY9GN6Ry4ilC70=";
|
|
|
|
x86_64-darwin = "sha256-UBUGjA+jUkT6p9714l8IvDDI/qhWNctVFOvcA2S5kQU=";
|
|
|
|
aarch64-linux = "sha256-2QAahqcM2gi3lT+18q2Nm9GNqVsqzX3RajBsTn+KB1c=";
|
|
|
|
aarch64-darwin = "sha256-uEH7Y7c9BcU/Q/jwx/inFMvUrgm2dUruID+FJL+rA6Y=";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
mainline = {
|
|
|
|
version = "2.10.1";
|
|
|
|
hash = {
|
|
|
|
x86_64-linux = "sha256-jNPL30e5xvyajlIqivtEpSb3cRhfgFhLFlC+CaLY2IM=";
|
|
|
|
x86_64-darwin = "sha256-U1eQaYwnm/mdQoZ8YxK/+s3HboVfMIAtdI7aQnCiDM8=";
|
|
|
|
aarch64-linux = "sha256-YtSyKZYG8vdubZUfo2FjEoVwSF82TXzeLJjPpHqgFDk=";
|
|
|
|
aarch64-darwin = "sha256-aQSiXK7voP5/mPFIscfTnSc4Ae5/f+WW8MR6ZtuC/eY=";
|
|
|
|
};
|
|
|
|
};
|
2022-11-21 17:40:18 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
in
|
|
|
|
stdenvNoCC.mkDerivation (finalAttrs: {
|
|
|
|
pname = "coder";
|
|
|
|
version = channels.${channel}.version;
|
|
|
|
src = fetchurl {
|
|
|
|
hash = (channels.${channel}.hash).${system};
|
|
|
|
|
|
|
|
url =
|
|
|
|
let
|
|
|
|
systemName = {
|
|
|
|
x86_64-linux = "linux_amd64";
|
|
|
|
aarch64-linux = "linux_arm64";
|
|
|
|
x86_64-darwin = "darwin_amd64";
|
|
|
|
aarch64-darwin = "darwin_arm64";
|
|
|
|
}.${system};
|
|
|
|
|
|
|
|
ext = {
|
|
|
|
x86_64-linux = "tar.gz";
|
|
|
|
aarch64-linux = "tar.gz";
|
|
|
|
x86_64-darwin = "zip";
|
|
|
|
aarch64-darwin = "zip";
|
|
|
|
}.${system};
|
|
|
|
in
|
|
|
|
"https://github.com/coder/coder/releases/download/v${finalAttrs.version}/coder_${finalAttrs.version}_${systemName}.${ext}";
|
2023-03-15 16:39:30 +00:00
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
makeBinaryWrapper
|
|
|
|
unzip
|
2023-03-15 16:39:30 +00:00
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
unpackPhase = ''
|
|
|
|
runHook preUnpack
|
2023-03-30 22:05:00 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
case $src in
|
|
|
|
*.tar.gz) tar -xz -f "$src" ;;
|
|
|
|
*.zip) unzip "$src" ;;
|
|
|
|
esac
|
2022-11-21 17:40:18 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
runHook postUnpack
|
|
|
|
'';
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
install -D -m755 coder $out/bin/coder
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
runHook postInstall
|
2023-03-15 16:39:30 +00:00
|
|
|
'';
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --cmd coder \
|
|
|
|
--bash <($out/bin/coder completion bash) \
|
|
|
|
--fish <($out/bin/coder completion fish) \
|
|
|
|
--zsh <($out/bin/coder completion zsh)
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
wrapProgram $out/bin/coder \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ terraform ]}
|
2022-11-21 17:40:18 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-30 22:05:00 +00:00
|
|
|
# integration tests require network access
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
meta = {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Provision remote development environments via Terraform";
|
2022-11-21 17:40:18 +00:00
|
|
|
homepage = "https://coder.com";
|
2024-04-21 15:54:59 +00:00
|
|
|
license = lib.licenses.agpl3Only;
|
|
|
|
mainProgram = "coder";
|
|
|
|
maintainers = with lib.maintainers; [ ghuntley urandom ];
|
|
|
|
};
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
updateScript = ./update.sh;
|
2022-11-21 17:40:18 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
})
|