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 17, 2024
1 parent 5f94e08 commit f38fc96
Show file tree
Hide file tree
Showing 4 changed files with 94 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.

63 changes: 63 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
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
pkgs.pre-commit

python
# Dependencies from pre-commit python scripts
# run `pre-commit run --all-files` to find out what you need.
pythonPackages.identify
pythonPackages.cfgv
pythonPackages.yamllint
];
# To prevent weird broken non-interactive bash terminal
buildInputs = [ pkgs.bashInteractive ];
shellHook = ''
if [ ! -f .git/hooks/pre-commit ]; then
pre-commit install
fi
# Cursorless .prettierrc depends on prettier-plugin-tailwindcss, which
# pre-commit won't auto-install. So we have to manually install it into the
# workspace until there is a nix package.
if ! pnpm ls prettier-plugin-tailwindcss | grep prettier >/dev/null; then
pnpm -w -D install prettier-plugin-tailwindcss
# This updates the pnpm-lock.yaml, which we don't want to keep
git restore pnpm-lock.yaml
fi
'';
};
}
);
};
}

0 comments on commit f38fc96

Please sign in to comment.