Repository navigation
Conversation
|
The PR itself does not change any derivation or package. It only provides a hook for nix-modules to be used in the nix packages configuration. |
There was a problem hiding this comment.
Wouldn't it make sense to make this a function?
|
I think it would be better if there was an actual usage, to estimate how close to the right approach this is. ;) |
|
What's the problem in doing imports = [ my-module-list.nix ]; instead ? On Sun, Oct 12, 2014 at 3:11 PM, Aristid Breitkreuz <
www.debian.org - The Universal Operating System |
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. 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".
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".
|
@aristidb , I don't quite understand what you want to make a function. Do you mean it should be possible to pass in a configuration through a function argument like for "nixpkgs/config.nix"? @lethalman, sorry, I'm lost. Where would you suggest to import what? |
|
@ts468 I don't get the usefulness of this PR, can you explain? If you want On Sun, Oct 12, 2014 at 4:06 PM, ts468 [email protected] wrote:
www.debian.org - The Universal Operating System |
|
@lethalman, what I want to have is a "nixuser" configuration file, similar to what "/etc/nixos/configuration.nix" is for NixOS. In particular for vimProfiles, I start with a configuration for different vim profiles, that is a collection of vim plugins and customized key bindings, and then generate a package for each vim profile. The packages can then be installed independently. It is also possible to declare and install the packages within the NixOS system configuration. Does that help and make sense? |
|
I just use nixops for my local system, and it works great. On Sun, Oct 12, 2014 at 5:42 PM, ts468 [email protected] wrote:
-----BEGIN PGP PUBLIC KEY BLOCK----- mQENBFEY1PEBCADPOfERF2wo4qeoq9L1m2z4pKfWqNd4B6BsoFUWPNd7BXmY+9JG |
There was a problem hiding this comment.
Any reason for not using ~/.nixpkgs/config.nix as a base file for user-land modules, from which we can extract options / config?
There was a problem hiding this comment.
For two reasons.
On the one hand I didn't want to change the way how ~/.nixpkgs/config.nix is used.
On the other hand the content of ~/.nixpkgs/config.nix can be integrated into ~/.nixuser/configuration.nix as attribute set nixpkgs.config. That way there would be a clear symmetry between the NixOS configuration under /etc/nixos/configuration.nix, and the new nixuser configuration under ~/.nixuser/configuration.nix
There was a problem hiding this comment.
I don't like having yet-another directory. Having this file under ~/.nixpkgs/configuration.nix would be better than ~/.nixuser directory. Then moving the package override within this configuration.nix file sounds indeed like a good idea for making configurations system wide.
To be honest I think this deserve its own pull-request, independently of the vim configuration.
There was a problem hiding this comment.
I'm just afraid that moving configuration.nix under ~/.nixpkgs as well could lead to confusions, especially for people who are new to Nix/NixOS. Wouldn't it be better to have it under ~/.nixuser for now, and then to phase out ~/.nixpkgs slowly?
I will provide a separated PR for the ~/.nixuser/configuration.nix related changes. The vimProfile stuff is only here to show a use case of the new configuration possibility.
|
I do not understand why these vim configuration is part of NixOS. |
|
@nbp, thank you very much for your detailed feedback and your suggestions how to improve the contribution! I highly appreciate it! About whether to have these modules next to the vim packages. You're right, they would somehow belong there. But as I haven't found any module definitions in the definitions under pkgs/... so far, I thought they would not belong there. Especially as there is nixos/modules/programs/..., where similar modules are placed. What would you suggest? Where would be the best place to put the modules under? |
I will look at it next week, ... We should move these out-side and make sure that we have default modules for user-profiles such as we can produce user-activation scripts, which can be sourced within shell configurations. Then these configurations would be used for both NixOS and Nixpkgs user configurations. |
|
@nbp, please let me know if I can be of any help or assistance with that! |
Deprecate ~/.nixpkgs/config.nix Create separate directory for nixuser nix modules. Improve coding style in vimProfiles/default.nix.
|
I would prefer do it entirely in then nixpkgs could provide sensiable default configurations for apps and profiles, overrided by user. |
|
Doesn't configuration modules and an overloaded NIX_PATH provide the same functionality as this PR, i.e. adding something like |
|
@iyzsong, the final goal is to have a declarative user environment, like also mentioned in the issue that you linked (#3990). However, " @edwtjo, I haven't tried what you suggested, so I don't know if it works, but even if it would, I still think it is not very convenient to use. |
|
Yes, It's what we all want.
IMO, this PR is not clean, and may be unnecessary. |
|
@ts468, I will probably take a few lines from the nixpkgs modificcation that you made, but by intent is to add a new directory at the top-level of nixpkgs, and make it such as the files which are under programs, can be shared by both nixos and this user-environment configuration. Thus these program specific configurations would have to be valid modules for both the user-environment configuration and nixos configurations (when possible). This way we would have a declarative way to define user-environments. I still have some work to do on the nix/secret branch, and I will get back to this ASAP. |
|
how about make here I introduce xterm.nix: related: #4505 |
|
@iyzsong, we should not configure programs by making wrappers, but by providing configuration files, such as .Xresources and using xrdb/xmerge to load it. Otherwise, yes, we could think of making ~/.nixpkgs/config.nix a part of a module, but I think we should look at this issue after. I have always been inclined avoid breaking previous stuff, but here we are bootstraping a new way to deal with the user environment, and I do not want that to be blocked on a non-existent issue. Currently ~/.nixpkgs/config.nix solves another problem which is selecting packages, and a nix user environment is about configuring these packages. |
|
@nbp, thank you very much for going to have a look at how to set up a nixuser environment! For me it's not urgent, so please take your time and finish your work on the nix/secret branch first. With my last changes I already set up a top level directory named "nixuser", which is structured similar to "nixos". The content of the new directory "nixuser" is automatically made available to nixos as well. If you're happy with that approach, I could have a look at moving further modules from nixos to nixuser. |
|
after some thinking, I hover @ts468, in the approach you show, all modules evaluated by a single @nbp, yeah, the xterm.nix is only a example, ideally I'll use needless to say, the |
|
The follow-up on this PR is #9250. |
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.
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".