-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
vim: add config option to generate global vimrc #959
Conversation
I think the usual way to handle configs is query them in all-packages.nix and pass the relevant option value only. |
Hi @Phreedom, With this new version, I believe I fixed the issues you mentioned. Thanks! |
The only thing I'm worried about here is that vim will be rebuild for each vimrc change, which seems a bit unfriendly |
@bbenoist: +1 for "splitting the thing in 2 projects". |
Yes, it seems better to do such things by some kind of a wrapper, so it isn't rebuilt because of each config change. |
@wizeman should we close this one until a wrapper is written? |
Ok, I've written the wrapper and done some basic testing, it seems to work and there's no need to recompile vim anymore. |
lgtm. |
vim: add config option to generate global vimrc
BTW, what was the motivation for this? I think such wrapper packages are in general a bad idea, since they confuse users (should they install "vim" or "vimWrapper"? how do you customize the wrapper? etc). |
@edolstra If you want to apply a certain vim configuration for all users, in most operating systems you just edit the /etc/vimrc file (as opposed to the per-user configuration in ~/.vim/vimrc). In NixOS, however, the idiomatic way to apply a certain configuration for all users is through /etc/nixos/configuration.nix, rather than directly editing files in /etc. So I needed a way to do that, and that's why I initially developed this feature. The wrapper was done to avoid rebuilding vim every time you change the vim configuration. |
Then IMHO the wrapper should be moved out of all-packages.nix (so it doesn't show up in nix-env) and into a NixOS module. Also, you can just do
to generate /etc/vimrc. |
Actually, I made a mistake, the default global location for vimrc is in /usr/share/vim. The wrapper works around this by starting vim with a VIM environment variable that points to $wrapperOut/share/vim. I know Ubuntu uses /etc/vim/vimrc, so if we want to, I guess we can patch vim to look for /etc/vimrc instead. Should I patch vim to use /etc/vimrc instead of /usr/share/vim/vimrc, then? And remove the wrapper, but create a module instead? |
@edolstra By the way, please note that a NixOS module is only useful for NixOS users, while a wrapper can be used by all nixpkgs users, independently of operating system. |
But people on other systems can just set the Yes, probably better to patch it to use /etc/vim/vimrc. |
Actually, no, because the VIM variable must point to vim's share directory, which not only contains the vimrc file but also contains other vim files... the wrapper actually copies vim's entire $out/ directory into vimwrapper's $out, so that vim can find those files. However, if we patch vim to use /etc/vim/vimrc (instead of $VIM/vimrc, which in nixpkgs, is equal to vim's $out/share/vim/vimrc) I think users from other operating systems can just create the vimrc file in /etc/vim and not even worry about setting VIM. I will work on this and create a new pull request once I make sure it works. |
Also, vim expressions are pretty individual, I don't see why they should be configured from global state? (/etc) Something that is missing from nixpkgs (and would benefit both nixos and non-nixos installs) is a de-facto environment variable loader, as well as a standard way of writing personal configuration files. The first could be as simple as configuration that ends up in etc/profile.d for the profile, and is sourced by /etc/profile + /etc/bash.bashrc on Nixos, and at the users' discretion elsewhere. It could be guarded by the hash against repeated inclusion. Then should be nixos-options in pkgs that write config files for things like vim and in fact anything that is not very core NixOS. Apache can also run as a regular user... |
There can be a few reasons to configure vim globally... for example, if you are the only person using some machine, but you have configured multiple users; or for example, if you want to apply some configuration defaults for your deployment which are different from the stock vim configuration. The latter is what Ubuntu does: by default, Ubuntu installs a global vimrc which enables some vim features by default, such as colored syntax (which almost everybody finds useful), among other features. It's useful to set global defaults when you're deploying software, even if some users want to further personalize the configuration. |
Agree, I also set some default options on vim system-wide like syntax, On Mon, Jun 2, 2014 at 7:05 PM, Ricardo M. Correia <[email protected]
www.debian.org - The Universal Operating System |
All that means is that when vim is installed as a system package, users will get it with the system configuration. If they install it in their profile they decide the config. |
No description provided.