Add nix flake (#1908)

Adds a flake I have been using for development on a Nix box, which I've
confirmed works to run pre-commit linting, correctly installs plugins,
can debug extension, etc.

## Checklist

- [-] I have added
[tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
- [-] I have updated the
[docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and
[cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet)
- [-] I have not broken the cheatsheet

Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
This commit is contained in:
Aaron Adams 2024-06-28 22:15:21 +08:00 committed by GitHub
parent 4eca0350da
commit 35b1af8222
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 87 additions and 0 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

3
.gitignore vendored
View File

@ -42,3 +42,6 @@ next-env.d.ts
# test subset config
packages/test-harness/testSubsetGrep.properties
# nix
.direnv/

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1709675310,
"narHash": "sha256-w61tqFEmuJ+/1rAwU7nkYZ+dN6sLwyobfLwX2Yn42FE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "43d259f8d726113fac056e8bb17d5ac2dea3e0a8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

56
flake.nix Normal file
View File

@ -0,0 +1,56 @@
{
description = "A Nix-flake-based development environment for Cursorless";
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; }; });
pythonVersion = builtins.replaceStrings [ "py" ] [
"python"
] (nixpkgs.lib.importTOML ./pyproject.toml).tool.ruff.target-version;
in
{
devShells = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.mkShell {
packages =
let
python = pkgs.${pythonVersion};
pythonPackages = pkgs."${pythonVersion}Packages";
in
[
pkgs.corepack
pkgs.vsce
# https://github.com/NixOS/nixpkgs/pull/251418
(pkgs.pre-commit.overrideAttrs (previousAttrs: {
makeWrapperArgs = ''
--set PYTHONPATH $PYTHONPATH
'';
}))
python
];
# To prevent weird broken non-interactive bash terminal
buildInputs = [ pkgs.bashInteractive ];
shellHook = ''
if [ ! -f .git/hooks/pre-commit ]; then
pre-commit install
fi
pnpm install
'';
};
}
);
};
}