Skip to content

Commit 0566d27

Browse files
committed
coder: fix web frontend building
1 parent 50c428d commit 0566d27

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{ lib, pkgs, fetchFromGitHub, installShellFiles, buildGoModule, fetchYarnDeps }:
2+
3+
let
4+
pname = "coder";
5+
version = "0.10.2";
6+
7+
src = fetchFromGitHub {
8+
owner = "coder";
9+
repo = "coder";
10+
rev = "v${version}";
11+
sha256 = "sha256-h5bN75agNocRAjShbufRCJr45huYJOzCBd4OcGpF4C4=";
12+
};
13+
14+
offlineCache = fetchYarnDeps {
15+
yarnLock = src + "/site/yarn.lock";
16+
sha256 = "sha256-uDNPRQTpsgxyC5ks+2Qq/wiKjkbjWwSO+cJc5X6qmAA=";
17+
};
18+
19+
yarn16 = pkgs.yarn.override { nodejs = pkgs.nodejs-16_x; };
20+
nodePackages16 = pkgs.nodePackages.override { nodejs = pkgs.nodejs-16_x; };
21+
in
22+
buildGoModule rec {
23+
inherit pname version src;
24+
25+
subPackages = [ "cmd/coder" ];
26+
27+
vendorSha256 = "sha256-+3Zy0zArCXkvD4ogfKdu9W9gJXveAhwFXKG1VRDvOkI=";
28+
29+
# Flags as provided by the build automation of the project:
30+
# https://github.com/coder/coder/blob/075e891f287b27cdb481a48e129f20a1e6a7de12/scripts/build_go.sh#L89
31+
ldflags = [
32+
"-s"
33+
"-w"
34+
"-X github.com/coder/coder/buildinfo.tag=${version}"
35+
];
36+
37+
preBuild = ''
38+
export HOME=$(mktemp -d)
39+
mkdir -p $HOME
40+
41+
cd site
42+
yarn config --offline set yarn-offline-mirror ${offlineCache}
43+
fixup_yarn_lock yarn.lock
44+
45+
# node-gyp tries to download always the headers and fails: https://github.com/NixOS/nixpkgs/issues/195404
46+
yarn remove --offline jest-canvas-mock canvas
47+
48+
NODE_ENV=production node node_modules/.bin/vite build
49+
cd ..
50+
'';
51+
52+
tags = [ "embed" ];
53+
54+
nativeBuildInputs = with pkgs; [
55+
fixup_yarn_lock
56+
nodejs-16_x
57+
yarn16
58+
nodePackages16.node-pre-gyp
59+
python3
60+
pkg-config
61+
installShellFiles
62+
];
63+
64+
postInstall = ''
65+
installShellCompletion --cmd coder \
66+
--bash <($out/bin/coder completion bash) \
67+
--zsh <($out/bin/coder completion zsh)
68+
'';
69+
70+
meta = with lib; {
71+
description = "Software development on any infrastructure";
72+
license = licenses.agpl3Only;
73+
homepage = "https://coder.com/";
74+
maintainers = with maintainers; [ shyim ];
75+
};
76+
}

pkgs/top-level/all-packages.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4174,6 +4174,8 @@ with pkgs;
41744174
electron = electron_11;
41754175
};
41764176

4177+
coder = callPackage ../applications/misc/coder {};
4178+
41774179
contrast = callPackage ../applications/accessibility/contrast { };
41784180

41794181
cplex = callPackage ../applications/science/math/cplex (config.cplex or {});

0 commit comments

Comments
 (0)