I’m running into a few issues that I’m not quite sure how to resolve ATM:
Resolved in Answer #1
- The binaries compiled with nix (including nix itself and HM) are all x86_64. This makes all the software run through Rosetta. While this is better than not working at all, the process launch lag gets in the way while using git, tig, shells, vim, etc. Is there a way to specify/override the arch and recompile certain binaries for arm64e? Nix thinks it’s running on a x86_64 machine:
$ nix repl Welcome to Nix version 2.3.10. Type :? for help.
nix-repl> :l <nixpkgs>
Added 12960 variables.
- Vim has clipboard problems when compiled thru home-manager (while system one works fine). If 1.) is not possible, is it possible to just use the system vim with home-manager provided configuration? Here’s a demo of what I’m trying to achieve:
$ lipo -info /usr/bin/vim
Architectures in the fat file: /usr/bin/vim are: x86_64 arm64e
$ cat $(which vim)
exec /nix/store/9bxb3khjdjdkg6604ypg7hpr7jhs4idz-vim_configurable-8.2.1522/bin/vim -u /nix/store/n08phrfgnbzghv01hvj3aab0khyy3q12-vimrc "$@"
$ lipo -info /nix/store/9bxb3khjdjdkg6604ypg7hpr7jhs4idz-vim_configurable-8.2.1522/bin/vim
Non-fat file: /nix/store/9bxb3khjdjdkg6604ypg7hpr7jhs4idz-vim_configurable-8.2.1522/bin/vim is architecture: x86_64
Is there a way to use system vim with -u /nix/store/n08phrfgnbzghv01hvj3aab0khyy3q12-vimrc dynamically? ATM I have a manual script invoking /usr/bin/vim -u /nix/store/n08phrfgnbzghv01hvj3aab0khyy3q12-vimrc. The downside of this approach is that the /nix/store path changes on every home-manager switch.
To answer question 1.) - seems like that’s a no-go according to the Swift core-team member https://twitter.com/jckarter/status/1345113504806653952?s=21
That’s specifically arm64e. Is regular arm64 not supported on M1 macOS?
You’re right, arm64 works ok. Still, nix is outputting x86_64 and not arm64.
I assume this depends on multiple things still in the pipeline (picking a few most-likely, but I’m not certain all apply and there may be more):
Thanks @abathur, great info!
So until all of these get in - let’s explore a possibility of the 2nd question: Can one use all the configuration from nix in a declarative way, and force specify a system binary?
This could technically be done in a couple of ways:
- nix exposes a symlink to where the config is. User creates a script or a symlink somewhere in ~/.local/bin and that path precedes everything in PATH
- nix / home manager has an option I don’t know of to specify the path to the binary to execute
- something else
To be fair, some programs like
fish just work with the first approach, and that is because home-manager copies the generated files into standard locations for
fish, i.e. $XDG_CONFIG/fish. It’s enough to just launch the shell and it automatically picks up nix-generated config. The problem are programs like vim, where nix doesn’t copy/link the generated config into ~/.vim, but has a dynamically generated path to vimrc, e.g.
There should be a cleaner way to do this (probably, yes, by figuring out how to write that config out to a stable $HOME-relative path–or perhaps by generating your own wrapper script during rebuild), though I’m not sure about specifics as I’m not familiar with home manager, it’s vim module, or the vim packaging in general
I’ll see if I can find someone on IRC…
Following up on this, I’ve ended using vim (and a few other binaries like git, tig, …) either manually built or OS provided. Home-manager doesn’t provide a solution asked above unfortunately, so I ended up just writing files by hand and sourcing them by path with nix/home-manager. This way nix takes care of ensuring the paths exist and are symlinked, and you can still use a binary of your choice. Looking forward for the above arm64 PRs to get in and remove this hacks.
Regarding question 2:
I don’t know whether that’s an acceptable solution to you, but after a while of debugging I finally gave in and switched to neovim which works fine out of the box with my existing configuration and does not have any clipboard problems.
set clipboard=unnamedplus works fine.
Thanks for sharing your solution, I do use neovim , but vim is installed everywhere and was demonstrating the issue well at the time of writing.
There’s been quite a few updates since this issue - native arm building works now in nix and the above hacks aren’t necessary anymore.