1{ lib
2, fetchFromGitHub
3, installShellFiles
4, makeWrapper
5, buildGoModule
6, fetchYarnDeps
7, fixup_yarn_lock
8, pkg-config
9, nodejs
10, yarn
11, nodePackages
12, python3
13, terraform
14}:
15
16buildGoModule rec {
17 pname = "coder";
18 version = "0.17.1";
19
20 src = fetchFromGitHub {
21 owner = pname;
22 repo = pname;
23 rev = "v${version}";
24 hash = "sha256-FHBaefwSGZXwn1jdU7zK8WhwjarknvyeUJTlhmk/hPM=";
25 };
26
27 offlineCache = fetchYarnDeps {
28 yarnLock = src + "/site/yarn.lock";
29 hash = "sha256-nRmEXR9fjDxvpbnT+qpGeM0Cc/qW/kN53sKOXwZiBXY=";
30 };
31
32 vendorHash = "sha256-+AvmJkZCFovE2+5Lg98tUvA7f2kBHUMzhl5IyrEGuy8=";
33
34 tags = [ "embed" ];
35
36 ldflags = [
37 "-s"
38 "-w"
39 "-X github.com/coder/coder/buildinfo.tag=${version}"
40 ];
41
42 subPackages = [ "cmd/..." ];
43
44 preBuild = ''
45 export HOME=$TEMPDIR
46
47 pushd site
48 yarn config --offline set yarn-offline-mirror ${offlineCache}
49 fixup_yarn_lock yarn.lock
50
51 # node-gyp tries to download always the headers and fails: https://github.com/NixOS/nixpkgs/issues/195404
52 yarn remove --offline jest-canvas-mock canvas
53
54 NODE_ENV=production node node_modules/.bin/vite build
55
56 popd
57 '';
58
59 nativeBuildInputs = [
60 fixup_yarn_lock
61 installShellFiles
62 makeWrapper
63 nodePackages.node-pre-gyp
64 nodejs
65 pkg-config
66 python3
67 yarn
68 ];
69
70 postInstall = ''
71 installShellCompletion --cmd coder \
72 --bash <($out/bin/coder completion bash) \
73 --fish <($out/bin/coder completion fish) \
74 --zsh <($out/bin/coder completion zsh)
75
76 wrapProgram $out/bin/coder --prefix PATH : ${lib.makeBinPath [ terraform ]}
77 '';
78
79 # integration tests require network access
80 doCheck = false;
81
82 meta = {
83 description = "Provision software development environments via Terraform on Linux, macOS, Windows, X86, ARM, and of course, Kubernetes";
84 homepage = "https://coder.com";
85 license = lib.licenses.agpl3;
86 maintainers = [ lib.maintainers.ghuntley lib.maintainers.urandom ];
87 # Failed to download Chromium 109.0.5414.46
88 broken = true; # At 2023-03-30
89 };
90}