Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nix flake for building extension #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ dist
node_modules
.vscode-test/
*.vsix
.direnv/
result/
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ Allows user to specify the denied commands using glob syntax, eg:

Defaults to `[]` (doesn't deny anything).

## Building

### Nix

The extension can be built using the `flake.nix` file using the following command:

```bash
nix build
```

The resulting `.vsix` file will be placed in the `result/` folder.

## Troubleshooting

## Known issues
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
description = "A Nix-flake-based development environment for command-server";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
packages = forEachSupportedSystem
({ pkgs, ... }:
let
attrs = with builtins; fromJSON (readFile ./package.json);
name = attrs.name;
version = attrs.version;
in
{
default = pkgs.mkYarnPackage {
pname = "${name}-${version}";
src = ./.;

buildPhase = ''
# yarn tries to create a .yarn file in $HOME. There's probably a
# better way to fix this but setting HOME to cwd works for now.
export HOME="."
yarn --offline run compile
# non-existent symlink errors during packaging
rm ./deps/command-server/command-server
# need node_modules for vsce, so don't use symlink
rm ./deps/command-server/node_modules
cp -R ./node_modules ./deps/command-server
pushd ./deps/command-server
echo y | yarn --offline vsce package --yarn -o ./$pname.vsix
popd
'';

installPhase = ''
mkdir $out
mv ./deps/command-server/$pname.vsix $out;
'';

distPhase = "true";

};
});

devShells = forEachSupportedSystem
({ pkgs }: {
default = pkgs.mkShell
{
packages = with pkgs;
[ yarn typescript ];
};
});
};
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"glob": "^7.1.6",
"mocha": "^8.1.3",
"typescript": "^4.1.2",
"vsce": "^2.15.0",
"vscode-test": "^1.4.1"
},
"dependencies": {
Expand Down
Loading