code-server: 3.4.1 -> 3.6.0

This commit is contained in:
Derek Guenther 2020-10-18 19:10:41 +00:00
parent 86102ebe5e
commit 680df517d7

View File

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, makeWrapper, runCommand { stdenv, fetchFromGitHub, buildGoModule, makeWrapper, runCommand
, moreutils, jq, git, zip, rsync, pkgconfig, yarn, python2 , moreutils, jq, git, zip, rsync, pkgconfig, yarn, python2
, nodejs-12_x, libsecret, xorg, ripgrep, nettools }: , nodejs-12_x, libsecret, xorg, ripgrep, nettools }:
@ -12,17 +12,31 @@ let
in stdenv.mkDerivation rec { in stdenv.mkDerivation rec {
pname = "code-server"; pname = "code-server";
version = "3.4.1"; version = "3.6.0";
commit = "d3773c11f147bdd7a4f5acfefdee23c26f069e76"; commit = "a4a03c14922ccaec2a9ff8d1b7b2af8522a4214d";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "cdr"; owner = "cdr";
repo = "code-server"; repo = "code-server";
rev = version; rev = "v${version}";
sha256 = "PfDD0waloppGZ09zCQ9ggBeVL/Dhfv6QmEs/fs7QLtA="; sha256 = "1c0p1s0bl3az5ysl97mz3gbynyndz6jd2jj7lx2snz6jqqd43y9p";
fetchSubmodules = true; fetchSubmodules = true;
}; };
cloudAgent = buildGoModule rec {
pname = "cloud-agent";
version = "0.1.0";
src = fetchFromGitHub {
owner = "cdr";
repo = "cloud-agent";
rev = version;
sha256 = "1p20cvgvs38604km9ixylz0r3k7blkd80lncmma3z05y5n5fqps1";
};
vendorSha256 = "0yky1v1ak3ysykjf3gm1hd7qyj5rm4fw7amga81sb31x0357jlzr";
};
yarnCache = stdenv.mkDerivation { yarnCache = stdenv.mkDerivation {
name = "${pname}-${version}-${system}-yarn-cache"; name = "${pname}-${version}-${system}-yarn-cache";
inherit src; inherit src;
@ -45,10 +59,10 @@ in stdenv.mkDerivation rec {
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHashAlgo = "sha256"; outputHashAlgo = "sha256";
# to get hash values use nix-build -A code-server.yarnPrefetchCache # to get hash values use nix-build -A code-server.prefetchYarnCache
outputHash = { outputHash = {
x86_64-linux = "Zze2hEm2Np+SyQ0KXy5CZr5wilZbHBYXNYcRJBUUkQo="; x86_64-linux = "1443qwkllb714s4qw3b9y1mcc6p2ykgc02pw2k3z2gczvvr0g8qv";
aarch64-linux = "LiIvGuBismWSL2yV2DuKUWDjIzuIQU/VVxtiD4xJ+6Q="; aarch64-linux = "1443qwkllb714s4qw3b9y1mcc6p2ykgc02pw2k3z2gczvvr0g8qv";
}.${system} or (throw "Unsupported system ${system}"); }.${system} or (throw "Unsupported system ${system}");
}; };
@ -64,7 +78,7 @@ in stdenv.mkDerivation rec {
]; ];
buildInputs = [ libsecret xorg.libX11 xorg.libxkbfile ]; buildInputs = [ libsecret xorg.libX11 xorg.libxkbfile ];
patchPhase = '' postPatch = ''
export HOME=$PWD export HOME=$PWD
patchShebangs ./ci patchShebangs ./ci
@ -76,6 +90,21 @@ in stdenv.mkDerivation rec {
substituteInPlace lib/vscode/build/npm/postinstall.js \ substituteInPlace lib/vscode/build/npm/postinstall.js \
--replace '--ignore-optional' '--offline' --replace '--ignore-optional' '--offline'
# remove unnecessary git config command
substituteInPlace lib/vscode/build/npm/postinstall.js \
--replace "cp.execSync('git config pull.rebase true');" ""
# allow offline install for postinstall scripts in extensions
grep -rl "yarn install" --include package.json lib/vscode/extensions \
| xargs sed -i 's/yarn install/yarn install --offline/g'
# remove download of coder-cloud agent
sed -i ':a;N;$!ba;s/OS=.*agent//' ci/build/npm-postinstall.sh
# use offline cache when installing release packages
substituteInPlace ci/build/npm-postinstall.sh \
--replace 'yarn --production' 'yarn --production --offline'
# fix path to ifconfig, so vscode can get mac address # fix path to ifconfig, so vscode can get mac address
substituteInPlace lib/vscode/src/vs/base/node/macAddress.ts \ substituteInPlace lib/vscode/src/vs/base/node/macAddress.ts \
--replace '/sbin/ifconfig' '${nettools}/bin/ifconfig' --replace '/sbin/ifconfig' '${nettools}/bin/ifconfig'
@ -111,8 +140,14 @@ in stdenv.mkDerivation rec {
# set nodedir, so we can build binaries later # set nodedir, so we can build binaries later
npm config set nodedir "${nodeSources}" npm config set nodedir "${nodeSources}"
# link coder-cloud agent from nix store
ln -s "${cloudAgent}/bin/cloud-agent" ./lib/coder-cloud-agent
# skip browser downloads for playwright # skip browser downloads for playwright
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true" export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true"
# skip unnecessary electron download
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
''; '';
buildPhase = '' buildPhase = ''
@ -162,6 +197,9 @@ in stdenv.mkDerivation rec {
# install only production dependencies # install only production dependencies
yarn --offline --cwd "$out/libexec/code-server" --production yarn --offline --cwd "$out/libexec/code-server" --production
# link coder-cloud agent from nix store
ln -s "${cloudAgent}/bin/cloud-agent" $out/libexec/code-server/lib/coder-cloud-agent
# create wrapper # create wrapper
makeWrapper "${nodejs-12_x}/bin/node" "$out/bin/code-server" \ makeWrapper "${nodejs-12_x}/bin/node" "$out/bin/code-server" \
--add-flags "$out/libexec/code-server/out/node/entry.js" --add-flags "$out/libexec/code-server/out/node/entry.js"