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

Add infrastruture: vimProfile #4432

Closed
wants to merge 4 commits into from
Closed

Add infrastruture: vimProfile #4432

wants to merge 4 commits into from

Conversation

ts468
Copy link
Contributor

@ts468 ts468 commented Oct 9, 2014

The PR was superseded by #4493


VimProfile allows to wrap vim with different configurations.
A configuration is composed by enabling and customizing pre-defined modules.
A module is a set of vim plugins and vimrc statements that are tightly linked.
Configurations are hierarchical and can inherit from each other.
The base of each hierarchy of configurations is a distingued default configuration.
Enabled vim configurations appear as normal package in nix, and have to be
installed accordingly.

The vimProfiles are declared either for system wide installations in
/etc/nixos/configuration.nix, or for each user in ~/.nixuser/configuration.nix.

An example for a vim configuration, here the content of ~/.nixuser/configuration.nix:

{ config, pkgs, ... }:
with pkgs;
{
programs.vim =
{ enable = true;
leader = " ";
general.enable = true;
statusline.enable = true;
profiles =
{ # Haskell configuration
hvim =
{ enable = true;
exec = { package = pkgs.vim_configurable; bin = "bin/vim"; };
search.enable = true;
# leader can be overwritten independently for each module
search.leader = "|";
text.enable = true;
sidebar.enable = true;
# overwrite default key binding
sidebar.toggleUndo = "uu";
completion.enable = true;
haskell.enable = true;
};
# graphical Haskell configuration
hqvim =
{ enable = true;
# set the name to call the wrapped vim
name = "Hvim";
parent = "hvim";
exec = { package = pkgs.qvim; bin = "bin/qvim"; };
# just as an example that inherited modules can also be disabled
search.enable = false;
};
# same configuration as for default, but with qvim
qvim =
{ # don't make that profile installable
enable = false;
exec = { package = pkgs.qvim; bin = "bin/qvim"; };
# if no name attribute is given, the attribute name
# of the configuration is taken: "qvim"
};
# alias declaration for qvim
gvim =
{ enable = true;
# inherit from a configuration by its attribute name
# you can inherit from a disabled configuration as well
parent = "qvim";
# add statement to the generated vimrc; it is inserted
# before any module statement
vimrc = ''
" Leader key timeout
set tm=2000
'';
};
};
};
}

The declaration above defines the following packages in nix:
"vimProfile.hvim", "vimProfile.hqvim" and "vimProfile.gvim".
When the default profile is enabled, it is automatically installed with
the package "vim".
An un-wrapped vim package is always available with "vimPlain".


Internals of the implementation:

A new file "nixos/modules/nixuser-module-list.nix" is added.
The file lists modules that are made available both for system configuration
and for user configuration.
The file is imported by "nixos/modules/module-list.nix" and is used in
"pkgs/top-level/all-packages.nix".

A new user specific configuration file is introduced.
It is located in "~/.nixuser/configuration.nix".
The idea is to have a declarative approach for defining the user environment
at some point. The configuration file acts as the input of a module evaluation
system, similar to "/etc/nixos/configuration.nix" for the NixOS configuration.

The configuration modules provided with vimProfile reduce to "nixpkgs.config"
attributes, which are added to the configuration of "~/.nixpkgs/config.nix".

Thomas Strobel added 4 commits October 9, 2014 10:39
VimProfile allows to wrap vim with different configurations.
A configuration is composed by enabling and customizing pre-defined modules.
A module is a set of vim plugins and vimrc statements that are tightly linked.
Configurations are hierarchical and can inherit from each other.
The base of each hierarchy of configurations is a distingued default configuration.
Enabled vim configurations appear as normal package in nix, and have to be
installed accordingly.

The vimProfiles are declared either for system wide installations in
/etc/nixos/configuration.nix, or for each user in ~/.nixuser/configuration.nix.

An example for a vim configuration, here the content of ~/.nixuser/configuration.nix:

{ config, pkgs, ... }:
with pkgs;
{
  programs.vim =
    { enable = true;
      leader = " ";
      general.enable = true;
      statusline.enable = true;
      profiles =
        {  # Haskell configuration
          hvim =
            { enable = true;
              exec = { package = pkgs.vim_configurable; bin = "bin/vim"; };
              search.enable = true;
              # leader can be overwritten independently for each module
              search.leader = "|";
              text.enable = true;
              sidebar.enable = true;
              # overwrite default key binding
              sidebar.toggleUndo = "<Leader>uu";
              completion.enable = true;
              haskell.enable = true;
            };
          # graphical Haskell configuration
          hqvim =
            { enable = true;
              # set the name to call the wrapped vim
              name = "Hvim";
              parent = "hvim";
              exec = { package = pkgs.qvim; bin = "bin/qvim"; };
              # just as an example that inherited modules can also be disabled
              search.enable = false;
            };
          # same configuration as for default, but with qvim
          qvim =
            { # don't make that profile installable
              enable = false;
              exec = { package = pkgs.qvim; bin = "bin/qvim"; };
              # if no name attribute is given, the attribute name
              # of the configuration is taken: "qvim"
            };
          # alias declaration for qvim
          gvim =
            { enable = true;
              # inherit from a configuration by its attribute name
              # you can inherit from a disabled configuration as well
              parent = "qvim";
              # add statement to the generated vimrc; it is inserted
              # before any module statement
              vimrc = ''
                " Leader key timeout
                set tm=2000
                '';
            };
        };
    };
}

The declaration above defines the following packages in nix:
"vimProfile.hvim", "vimProfile.hqvim" and "vimProfile.gvim".
When the default profile is enabled, it is automatically installed with
the package "vim".
An un-wrapped vim package is always available with "vimPlain".

-------------------

Internals of the implementation:

A new file "nixos/modules/nixuser-module-list.nix" is added.
The file lists modules that are made available both for system configuration
and for user configuration.
The file is imported by "nixos/modules/module-list.nix" and is used in
"pkgs/top-level/all-packages.nix".

A new user specific configuration file is introduced.
It is located in "~/.nixuser/configuration.nix".
The idea is to have a declarative approach for defining the user environment
at some point. The configuration file acts as the input of a module evaluation
system, similar to "/etc/nixos/configuration.nix" for the NixOS configuration.

The configuration modules provided with vimProfile reduce to "nixpkgs.config"
attributes, which are added to the configuration of "~/.nixpkgs/config.nix".
@ts468
Copy link
Contributor Author

ts468 commented Oct 9, 2014

I can't figure out why Travis CI build fails. It all works locally on my system --- at least it seems to :)

Could someone maybe give it a try, nevertheless?

I would also very much like to hear about what you think about it. Any feedback would be highly appreciated!

@Fuuzetsu Fuuzetsu added the 0.kind: enhancement Add something new label Oct 11, 2014
@ts468
Copy link
Contributor Author

ts468 commented Oct 12, 2014

Close PR and split it into smaller parts.

The PR was superseded by #4493

@ts468 ts468 closed this Oct 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants