summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2023-06-13 15:07:58 +0200
committerPol Dellaiera <pol.dellaiera@protonmail.com>2023-06-13 15:07:58 +0200
commit4f73991ab98ec266291996a71ded1081a1ee6e59 (patch)
treeae4b58f4fadda7cfe3d6cd4acd91ac7e63904646
parent40b63ec92d649effaca76bf0e2b3773f0136f91a (diff)
openvscode-server: use `finalAttrs` pattern
-rw-r--r--pkgs/servers/openvscode-server/default.nix79
1 files changed, 60 insertions, 19 deletions
diff --git a/pkgs/servers/openvscode-server/default.nix b/pkgs/servers/openvscode-server/default.nix
index b49394ab5291..17c53a2de8ff 100644
--- a/pkgs/servers/openvscode-server/default.nix
+++ b/pkgs/servers/openvscode-server/default.nix
@@ -1,13 +1,32 @@
-{ lib, stdenv, fetchFromGitHub, buildGoModule, makeWrapper
-, cacert, moreutils, jq, git, pkg-config, yarn, python3
-, esbuild, nodejs, libsecret, xorg, ripgrep
-, AppKit, Cocoa, Security, cctools, nixosTests }:
+{ lib
+, stdenv
+, fetchFromGitHub
+, buildGoModule
+, makeWrapper
+, cacert
+, moreutils
+, jq
+, git
+, pkg-config
+, yarn
+, python3
+, esbuild
+, nodejs
+, libsecret
+, xorg
+, ripgrep
+, AppKit
+, Cocoa
+, Security
+, cctools
+, nixosTests
+}:
let
system = stdenv.hostPlatform.system;
yarn' = yarn.override { inherit nodejs; };
- defaultYarnOpts = [ "frozen-lockfile" "non-interactive" "no-progress"];
+ defaultYarnOpts = [ "frozen-lockfile" "non-interactive" "no-progress" ];
vsBuildTarget = {
x86_64-linux = "linux-x64";
@@ -30,27 +49,27 @@ let
};
# replaces esbuild's download script with a binary from nixpkgs
- patchEsbuild = path : version : ''
+ patchEsbuild = path: version: ''
mkdir -p ${path}/node_modules/esbuild/bin
jq "del(.scripts.postinstall)" ${path}/node_modules/esbuild/package.json | sponge ${path}/node_modules/esbuild/package.json
sed -i 's/${version}/${esbuild'.version}/g' ${path}/node_modules/esbuild/lib/main.js
ln -s -f ${esbuild'}/bin/esbuild ${path}/node_modules/esbuild/bin/esbuild
'';
-
-in stdenv.mkDerivation rec {
+in
+stdenv.mkDerivation (finalAttrs: {
pname = "openvscode-server";
version = "1.79.0";
src = fetchFromGitHub {
owner = "gitpod-io";
repo = "openvscode-server";
- rev = "openvscode-server-v${version}";
+ rev = "openvscode-server-v${finalAttrs.version}";
hash = "sha256-dVzGyK1ybZywCm602zWJroSCQ2wx5IzV+HqwZUsEgKU=";
};
yarnCache = stdenv.mkDerivation {
- name = "${pname}-${version}-${system}-yarn-cache";
- inherit src;
+ name = "${finalAttrs.pname}-${finalAttrs.version}-${system}-yarn-cache";
+ inherit (finalAttrs) src;
nativeBuildInputs = [ cacert yarn' git ];
buildPhase = ''
export HOME=$PWD
@@ -72,13 +91,23 @@ in stdenv.mkDerivation rec {
};
nativeBuildInputs = [
- nodejs yarn' python3 pkg-config makeWrapper git jq moreutils
+ nodejs
+ yarn'
+ python3
+ pkg-config
+ makeWrapper
+ git
+ jq
+ moreutils
];
buildInputs = lib.optionals (!stdenv.isDarwin) [ libsecret ]
++ (with xorg; [ libX11 libxkbfile ])
++ lib.optionals stdenv.isDarwin [
- AppKit Cocoa Security cctools
- ];
+ AppKit
+ Cocoa
+ Security
+ cctools
+ ];
patches = [
# Patch out remote download of nodejs from build script
@@ -100,19 +129,25 @@ in stdenv.mkDerivation rec {
'';
configurePhase = ''
+ runHook preConfigure
+
# set default yarn opts
${lib.concatMapStrings (option: ''
yarn --offline config set ${option}
'') defaultYarnOpts}
# set offline mirror to yarn cache we created in previous steps
- yarn --offline config set yarn-offline-mirror "${yarnCache}"
+ yarn --offline config set yarn-offline-mirror "${finalAttrs.yarnCache}"
# set nodedir, so we can build binaries later
npm config set nodedir "${nodejs}"
+
+ runHook postConfigure
'';
buildPhase = ''
+ runHook preBuild
+
# install dependencies
yarn --offline --ignore-scripts
@@ -155,27 +190,33 @@ in stdenv.mkDerivation rec {
# build and minify
yarn --offline gulp vscode-reh-web-${vsBuildTarget}-min
+
+ runHook postBuild
'';
installPhase = ''
+ runHook preInstall
+
mkdir -p $out
cp -R -T ../vscode-reh-web-${vsBuildTarget} $out
ln -s ${nodejs}/bin/node $out
+
+ runHook postInstall
'';
passthru.tests = {
inherit (nixosTests) openvscode-server;
};
- meta = with lib; {
+ meta = {
description = "Run VS Code on a remote machine";
longDescription = ''
Run upstream VS Code on a remote machine with access through a modern web
browser from any device, anywhere.
'';
homepage = "https://github.com/gitpod-io/openvscode-server";
- license = licenses.mit;
- maintainers = with maintainers; [ dguenther ghuntley emilytrau ];
+ license = lib.licenses.mit;
+ maintainers = with lib.maintainers; [ dguenther ghuntley emilytrau ];
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
-}
+})