From a70ecaa731971dcfc695a6ea41b079fa2fc5e8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20R=C3=B3=C5=BCycki?= Date: Sat, 2 Mar 2024 01:42:32 +0100 Subject: [PATCH] Fix default.nix to enable building with nix-build With this change it is now possible to build the extension by just running `nix-build` inside the repository root directory. The packaged extension will be available in `result/bin` directory. --- .gitignore | 1 + default.nix | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index ff59f74..bbc7ffa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ node_modules .vscode-test/ *.vsix secrets +result diff --git a/default.nix b/default.nix index fe6e2f9..41517cb 100644 --- a/default.nix +++ b/default.nix @@ -1,17 +1,29 @@ { nixpkgs ? import {} }: let - inherit (nixpkgs) pkgs; + inherit (nixpkgs) lib pkgs stdenv; nixPackages = [ - pkgs.nodejs-12_x + pkgs.nodejs pkgs.jdk11 - ]; + pkgs.vsce + ] ++ lib.optional stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.Security; + packageJson = (lib.importJSON ./package.json); in -pkgs.stdenv.mkDerivation { - name = "vscode-env-selector"; +pkgs.stdenv.mkDerivation rec { + pname = packageJson.name; + version = packageJson.version; + + src = ./.; + buildInputs = nixPackages; - postInstall = - '' - yarn install - ''; + buildPhase = '' + npm install + npm run compile + echo y | vsce package + ''; + + installPhase = '' + mkdir -p $out/bin + cp ${pname}-${version}.vsix $out/bin + ''; }