-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nix flake #1908
Add nix flake #1908
Conversation
Sorry I'm not familiar with nix flake. What is this PR doing? |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
Nix flakes are basically packaging management files (written in the nix functional programming language) that projects can add that allow the nix package manager to automatically setup a shell environment of locked packages, without globally installing them. So basically someone can just activate the flake development environment and everything needed to develop/build is automatically installed there. Assuming a project is something actually packaged like an installable tool, you can also have the flake describe how to build the package for you so you can install/run it. Not sure how that works for vscode extension installation in nix and didn't bother looking yet. Nix is used for package package management by Mac (replacement for homebrew) and Linux users wanting fully reproducible environments, and also is what NixOS is centered around using. I'm doing the cursorless hacking from a NixOS setup, so just threw it together and figured I'd send a PR in case it would be useful for other nix users that might hack on cursorless in the future. That said, I totally appreciate if you don't want to add this :D |
Reproducibility is my middle name. I'll have a look |
I did try out this PR on x86 macOS, and it appears to work as expected, with the known caveat that if you run VSCode within a nix environment then the command server and Talon command client will fail to find each other. I'll admit I didn't test it for too long though, and still need to check the pre-commit hook installed correctly (but that looks correct 😅) |
Is that known caveat detailed anywhere? Is it Mac specific? I don't have that problem on NixOS afaik, as I've been using talon/cursorless for the development. The pre-commit hooks seemed to install for me and run fine when I sent the other PRs but definitely worth someone else verifying. |
I noted it somewhere once I worked out the mismatching $TMPDIR was the issue. Might be mentioned in the talonhub/community issues. Edit: here we are: talonhub/community#966 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to completely defer to @auscompgeek to review this one, as I'm way out of my depth. I left one comment tho to give the appearance of being useful / competent 🤓
Since I just had to force push again (I seem to do this a lot in my PRs), I'm curious if someone can tell me the trick to merge upstream changes into the PR branch without it triggering like a thousand file updates? I don't seem to easily find an explanation of what I'm missing, but you folks presumably know. I do know about the button in the github interface, but presumably there is some "right" cli way |
I think you're just seeing GitHub's eventual consistency behaviour? I see 1 commit with 3 files changed, which I presume is expected. |
Hrm, I'll look into what that is. But in this case it's only the 3 files changed because I force pushed. I did a soft reset back to a shared commit with upstream, rebase, then apply a new commit with all my changes and force push. |
@auscompgeek are you happy with this PR? As mentioned above I don't know enough about nix to be a competent reviewer here |
I'll start tweaking this again so I can use it to build/test neovim, but it would still be nice to get it in as is in the meantime, as I still have to pull it into every new branch I create atm if I want to test anything. Happy to change anything else needed. |
Haven't tried this but I think it's a great idea. Maybe I'll try nix again in the future. |
@auscompgeek I'm just waiting for an approval from you on this one and I'll merge |
Looks like switching to corepack breaks one of the pre-commit hooks. Wasn't something I had tested after switching. Will revert that change and just stick with hardcoded node 18 package for now I think. If it breaks in the future because someone updates package.json then I'll fix the flake. Doesn't seem any different than corepack breaking things now, so I'd rather just stick to what works atm. Can see more context here That said, there is another pre-commit hook related bug introduced as of March, that both versions of the flake, which is that the prettier hook now has an external npm dependency that pre-commit itself won't auto install, as it's specific to |
Did some more testing while fixing the tailwind issue and it seems like the I ran |
When I re-run ❯ direnv allow
direnv: loading ~/dev/talon/fidgetingbits-cursorless/.envrc
direnv: using flake
direnv: nix-direnv: using cached dev shell
Scope: all 12 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
WARN Failed to create bin at /home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-config/node_modules/.
bin/ts-node. ENOENT: no such file or directory, chmod '/home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/je
st-config/node_modules/.bin/ts-node'
WARN Failed to create bin at /home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_@[email protected]__es_x5o3lutkgkkiogdpvhimm74uee/node_modul
es/ts-jest/node_modules/.bin/jest. ENOENT: no such file or directory, chmod '/home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_@babel+core@7.
24.3__es_x5o3lutkgkkiogdpvhimm74uee/node_modules/ts-jest/node_modules/.bin/jest'
WARN Failed to create bin at /home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@webpack-cli+genera_o5z57zhf57uxuhfj26re5e4zha/node_modul
es/html-webpack-plugin/node_modules/.bin/html-minifier-terser. ENOENT: no such file or directory, chmod '/home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected][email protected][email protected]_w
[email protected]_@webpack-cli+genera_o5z57zhf57uxuhfj26re5e4zha/node_modules/html-webpack-plugin/node_modules/.bin/html-minifier-terser'
WARN Failed to create bin at /home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_@[email protected]__es_x5o3lutkgkkiogdpvhimm74uee/node_modul
es/ts-jest/node_modules/.bin/semver. ENOENT: no such file or directory, chmod '/home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_@babel+core@
7.24.3__es_x5o3lutkgkkiogdpvhimm74uee/node_modules/ts-jest/node_modules/.bin/semver'
WARN Failed to create bin at /home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@webpack-cli+genera_o5z57zhf57uxuhfj26re5e4zha/node_modul
es/html-webpack-plugin/node_modules/.bin/webpack. ENOENT: no such file or directory, chmod '/home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected][email protected][email protected]_webpack-cli@5.
1.4_@webpack-cli+genera_o5z57zhf57uxuhfj26re5e4zha/node_modules/html-webpack-plugin/node_modules/.bin/webpack'
WARN 15 other warnings
Done in 1.8s
direnv: export +DETERMINISTIC_BUILD +PYTHONHASHSEED +PYTHONNOUSERSITE +PYTHONPATH +_PYTHON_HOST_PLATFORM +_PYTHON_SYSCONFIGDATA_NAME +buildPhase +dontAddDisableDepTrack +phases +preferLocalBuild +shellHook ~CONFIG_SHELL ~HOST
_PATH ~NIX_BINTOOLS ~NIX_CC ~NIX_CFLAGS_COMPILE ~NIX_LDFLAGS ~PATH ~XDG_DATA_DIRS ~buildInputs ~builder ~name ~nativeBuildInputs ~out ~shell ~stdenv The files do seem to exist though, for example the first warning: ❯ ls -al /home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-config/node_modules/.bin/ts-node
.rwxr-xr-x 1.4k aa 18 6月 17:24 /home/aa/dev/talon/fidgetingbits-cursorless/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-config/node_modul
es/.bin/ts-node Seems things mostly function (tested |
This PR is getting (quite) long in the tooth 😅 so I decided to try it out locally myself in preparation for merging it. I've never used nix before. Seems like it's working to me, so I'd be inclined to merge. Here's what I did from top to bottom: ➜ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
info: downloading installer https://install.determinate.systems/nix/tag/v0.19.0/nix-installer-aarch64-darwin
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
Password:
Nix install plan (v0.19.0)
Planner: macos (with default settings)
Planned actions:
* Create an encrypted APFS volume `Nix Store` for Nix on `disk3` and add it to `/etc/fstab` mounting on `/nix`
* Extract the bundled Nix (originally from /nix/store/xsmwdm9d3br9mhi14msbf346zfv7v56l-nix-binary-tarball-2.21.2/nix-2.21.2-aarch64-darwin.tar.xz)
* Create a directory tree in `/nix`
* Move the downloaded Nix into `/nix`
* Create build users (UID 301-332) and group (GID 30000)
* Configure Time Machine exclusions
* Setup the default Nix profile
* Place the Nix configuration in `/etc/nix/nix.conf`
* Configure the shell profiles
* Configuring zsh to support using Nix in non-interactive shells
* Create a `launchctl` plist to put Nix into your PATH
* Configure Nix daemon related settings with launchctl
* Remove directory `/nix/temp-install-dir`
Proceed? ([Y]es/[n]o/[e]xplain):
INFO Step: Create an encrypted APFS volume `Nix Store` for Nix on `disk3` and add it to `/etc/fstab` mounting on `/nix`
INFO Step: Provision Nix
INFO Step: Create build users (UID 301-332) and group (GID 30000)
INFO Step: Configure Time Machine exclusions
INFO Step: Configure Nix
INFO Step: Configuring zsh to support using Nix in non-interactive shells
INFO Step: Create a `launchctl` plist to put Nix into your PATH
INFO Step: Configure Nix daemon related settings with launchctl
INFO Step: Remove directory `/nix/temp-install-dir`
Nix was installed successfully!
To get started using Nix, open a new shell or run `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh`
➜ . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
➜ nix run "nixpkgs#hello"
Hello, world!
➜ nix build
error: flake 'git+file:///Users/pokey/src/cursorless' does not provide attribute 'packages.aarch64-darwin.default' or 'defaultPackage.aarch64-darwin'
➜ nix develop
bash: /Users/pokey/.rc: No such file or directory
pre-commit installed at .git/hooks/pre-commit
Scope: all 12 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
╭─────────────────────────────────────────────────────────────────╮
│ │
│ Update available! 9.0.6 → 9.4.0. │
│ Changelog: https://github.com/pnpm/pnpm/releases/tag/v9.4.0 │
│ Run "corepack prepare [email protected] --activate" to update. │
│ │
│ Follow @pnpmjs for updates: https://twitter.com/pnpmjs │
│ │
╰─────────────────────────────────────────────────────────────────╯
Done in 2.8s
(nix:nix-shell-env) pokey@MacBook-Pro-9:~/src/cursorless$ ls
CHANGELOG.md bashbooks cursorless-talon flake.lock out pyproject.toml tsconfig.json
CONTRIBUTING.md bundle.vsix cursorless-talon-dev flake.nix package.json queries typings
LICENSE bundles cursorless.nvim fonts packages schemas
NOTICE.md changelog data images patches scripts
README.md cursorless-development-0.26.0.vsix dist netlify.toml pnpm-lock.yaml third-party-licenses.csv
SECURITY.md cursorless-snippets docs node_modules pnpm-workspace.yaml tsconfig.base.json
(nix:nix-shell-env) pokey@MacBook-Pro-9:~/src/cursorless$ pnpm transform-recorded-tests
> [email protected] transform-recorded-tests /Users/pokey/src/cursorless
> ./packages/common/scripts/my-ts-node.js packages/cursorless-engine/src/scripts/transformRecordedTests/index.ts You can see in that last step that I'm successfully running one of our scripts, so I think I'll declare victory. @auscompgeek if there's any remaining improvements you think we should make, it would be awesome if you could file a quick follow-up issue. Thanks to everyone involved here! |
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