Skip to content

Commit

Permalink
feat: working debug on nix
Browse files Browse the repository at this point in the history
  • Loading branch information
fidgetingbits committed Jun 24, 2024
1 parent cdaf58e commit 1cdf49e
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 1 deletion.
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 @@ -46,3 +46,6 @@ packages/test-harness/testSubsetGrep.properties

cursorless.nvim/node/cursorless-neovim
cursorless.nvim/node/test-harness

# 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.

96 changes: 96 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
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;
overlays = [
# https://github.com/NixOS/nixpkgs/pull/317333
(final: prev: {
nodePackages = prev.nodePackages // {
neovim = prev.buildNpmPackage rec {
pname = "neovim-node-client";
version = "5.1.1-dev.0";
src = prev.fetchFromGitHub {
owner = "neovim";
repo = "node-client";
rev = "d99ececf115ddc8ade98467417c1bf0120b676b5";
hash = "sha256-eiKyhJNz7kH2iX55lkn7NZYTj6yaSZLMZxqiqPxDIPs=";
};
npmDeps = prev.fetchNpmDeps {
inherit src;
hash = "sha256-UoMq+7evskxtZygycxLBgeUtwrET8jYKeZwMiXdBMAw=";
};
postInstall = ''
mkdir -p $out/bin
ln -s $out/lib/node_modules/neovim/node_modules/.bin/neovim-node-host $out/bin
'';
};
};
neovim = prev.neovim.override { withNodeJs = true; };

})

];
};
}
);
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
pkgs.neovim
];
# 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
PATH=${pkgs.lib.getBin pkgs.neovim}/bin:$PATH}
'';
};
}
);
};
}
2 changes: 1 addition & 1 deletion packages/cursorless-neovim/scripts/debug-neovim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export NVIM_NODE_LOG_FILE="${workspaceFolder}/packages/cursorless-neovim/out/nvi
export NVIM_NODE_LOG_LEVEL="info"
export CURSORLESS_MODE="${cursorless_mode}"

nvim -u "${workspaceFolder}/init.lua"
command nvim -u "${workspaceFolder}/init.lua"
3 changes: 3 additions & 0 deletions packages/cursorless-neovim/scripts/populate-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
set -euo pipefail

echo "Populating dist directory..."
if [ ! -e "${CURSORLESS_REPO_ROOT-nonexistent}" ]; then
CURSORLESS_REPO_ROOT=$(git rev-parse --show-toplevel)
fi
echo "CURSORLESS_REPO_ROOT: $CURSORLESS_REPO_ROOT"
cursorless_nvim_dir="$CURSORLESS_REPO_ROOT/cursorless.nvim"
cursorless_neovim_node_in_dir="$CURSORLESS_REPO_ROOT/packages/cursorless-neovim"
Expand Down

0 comments on commit 1cdf49e

Please sign in to comment.