Skip to content

Commit 35b1af8

Browse files
fidgetingbitspokey
andauthored
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 <[email protected]>
1 parent 4eca035 commit 35b1af8

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ next-env.d.ts
4242

4343
# test subset config
4444
packages/test-harness/testSubsetGrep.properties
45+
46+
# nix
47+
.direnv/

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
description = "A Nix-flake-based development environment for Cursorless";
3+
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
6+
outputs =
7+
{ self, nixpkgs }:
8+
let
9+
supportedSystems = [
10+
"x86_64-linux"
11+
"aarch64-linux"
12+
"x86_64-darwin"
13+
"aarch64-darwin"
14+
];
15+
forEachSupportedSystem =
16+
f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
17+
pythonVersion = builtins.replaceStrings [ "py" ] [
18+
"python"
19+
] (nixpkgs.lib.importTOML ./pyproject.toml).tool.ruff.target-version;
20+
in
21+
{
22+
devShells = forEachSupportedSystem (
23+
{ pkgs }:
24+
{
25+
default = pkgs.mkShell {
26+
packages =
27+
let
28+
python = pkgs.${pythonVersion};
29+
pythonPackages = pkgs."${pythonVersion}Packages";
30+
in
31+
[
32+
pkgs.corepack
33+
pkgs.vsce
34+
# https://github.com/NixOS/nixpkgs/pull/251418
35+
(pkgs.pre-commit.overrideAttrs (previousAttrs: {
36+
makeWrapperArgs = ''
37+
--set PYTHONPATH $PYTHONPATH
38+
'';
39+
}))
40+
41+
python
42+
];
43+
# To prevent weird broken non-interactive bash terminal
44+
buildInputs = [ pkgs.bashInteractive ];
45+
shellHook = ''
46+
if [ ! -f .git/hooks/pre-commit ]; then
47+
pre-commit install
48+
fi
49+
50+
pnpm install
51+
'';
52+
};
53+
}
54+
);
55+
};
56+
}

0 commit comments

Comments
 (0)