Skip to content

Commit

Permalink
Add nix flake for dev shell
Browse files Browse the repository at this point in the history
  • Loading branch information
fidgetingbits committed Jun 18, 2024
1 parent 5f94e08 commit bddaaea
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ next-env.d.ts

# test subset config
packages/test-harness/testSubsetGrep.properties

# nix
.direnv/
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.

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}
);
};
}

0 comments on commit bddaaea

Please sign in to comment.