Skip to content
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

Merged
merged 1 commit into from
Mar 7, 2014

Conversation

wizeman
Copy link
Member

@wizeman wizeman commented Sep 13, 2013

No description provided.

@Phreedom
Copy link
Member

I think the usual way to handle configs is query them in all-packages.nix and pass the relevant option value only.
What happens if vim config contains ' ?

@wizeman
Copy link
Member Author

wizeman commented Sep 23, 2013

Hi @Phreedom,

With this new version, I believe I fixed the issues you mentioned.

Thanks!

@domenkozar
Copy link
Member

The only thing I'm worried about here is that vim will be rebuild for each vimrc change, which seems a bit unfriendly

@bjornfor
Copy link
Contributor

@bbenoist: +1 for "splitting the thing in 2 projects".

@vcunat
Copy link
Member

vcunat commented Jan 26, 2014

Yes, it seems better to do such things by some kind of a wrapper, so it isn't rebuilt because of each config change.

@domenkozar
Copy link
Member

@wizeman should we close this one until a wrapper is written?

@wizeman
Copy link
Member Author

wizeman commented Feb 20, 2014

Ok, I've written the wrapper and done some basic testing, it seems to work and there's no need to recompile vim anymore.

@domenkozar
Copy link
Member

lgtm.

domenkozar added a commit that referenced this pull request Mar 7, 2014
vim: add config option to generate global vimrc
@domenkozar domenkozar merged commit 152f87c into NixOS:master Mar 7, 2014
@wizeman wizeman deleted the vimrc branch March 10, 2014 00:23
@edolstra
Copy link
Member

edolstra commented Jun 2, 2014

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

@wizeman
Copy link
Member Author

wizeman commented Jun 2, 2014

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

@edolstra
Copy link
Member

edolstra commented Jun 2, 2014

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

environment.etc.vimrc.text = "bla bla";

to generate /etc/vimrc.

@wizeman
Copy link
Member Author

wizeman commented Jun 2, 2014

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?

@wizeman
Copy link
Member Author

wizeman commented Jun 2, 2014

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

@edolstra
Copy link
Member

edolstra commented Jun 2, 2014

But people on other systems can just set the VIM environment variable, right?

Yes, probably better to patch it to use /etc/vim/vimrc.

@wizeman
Copy link
Member Author

wizeman commented Jun 2, 2014

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.

@wmertens
Copy link
Contributor

wmertens commented Jun 2, 2014

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

@wizeman
Copy link
Member Author

wizeman commented Jun 2, 2014

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.

@lucabrunox
Copy link
Contributor

Agree, I also set some default options on vim system-wide like syntax,
common keys on modern systems, ...

On Mon, Jun 2, 2014 at 7:05 PM, Ricardo M. Correia <[email protected]

wrote:

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.


Reply to this email directly or view it on GitHub
#959 (comment).

www.debian.org - The Universal Operating System

@wmertens
Copy link
Contributor

wmertens commented Jun 2, 2014

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.
Either way should use the same expression...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants