7

I read a bit about NixOS and tried it these days, because I got the impression that it would let me configure a Linux with just one file.

When I used it, I installed a bunch of packages with nix-env, so they didn't end up in the configuration.nix, but I could simply uninstall them later and add them to the configuration.nix by hand. I there something like npm i -g <package> that would install this globally so it would end up in the configuration.nix and could simply be copied to another machine.

Also, I installed stuff like zsh and atom and they have an entirely different approach to configuration and customization (bashscript, javascript, less, etc).

Is there a way for Nix/NixOS to track the package-specific config too?

Does it already happen and I don't see it? Like the nix expression of the package knows where the package will store its config etc.

I mean, it's nice that I can add these packages to the main config and when using it at another PC I get the same software installed, but I still see myself writing rather much configs for the installed packages too.

K..
  • 4,044
  • 6
  • 40
  • 85

2 Answers2

9
  1. If you want packages installed through configuration.nix, then the easiest way to accomplish that is to add them to the environment.systemPackages attribute. Packages listed in there will be available automatically to all users on the machine. As far as I know, there is no shell command available to automate the maintenance of that attribute, though. The only way to manage that list is by editing configuration.nix and manually adding the packages you'd like to have installed.

  2. Nix does not manage package-specific configuration files. As you probably know, NixOS provides such a mechanism for files in /etc, but a similar mechanism to manage config files in $HOME etc. does not exist. The PR https://github.com/NixOS/nixpkgs/pull/9250 on Github contains a concrete proposal to add this capability to Nix, but it hasn't been merged yet because it requires some changes that are controversial.

Peter Simons
  • 1,752
  • 17
  • 17
  • Yes I saw that PR after I posted this. Seems like even if it is merged, an Atom config is still JavaScript and not a Nix Expression. So versioning this myself will probably always be the case. – K.. Jan 05 '16 at 17:14
  • 1
    In Nix world, it's usually done this way that Nix packages ("expressions") describing particular app *generate* the app-specific config files (.json, .ini, .rc, .xml, or whatever else) under the wraps, based on "pretty" config options which can be tweaked from *configuration.nix* (or *~/.nixpkgs/config.nix*). The options are usually exposed on "as needed" basis by package writers (if you learn Nix, you can try to do it yourself!); also, not all apps make it easy (one has to override default location of config file to point into auto-generated file in */nix/store/*). – akavel Jul 21 '16 at 19:11
2

Nix does not currently offer ways of managing user specific configuration or language specific package managers. AFAICT that's because it is a very complex and opinionated territory compared to generating configs for sshd etc.

There are however Nix-based projects providing solution to at least some parts of your question. For managing user configuration (zsh etc.), have a look at home manager.

Vojtech Kane
  • 559
  • 6
  • 21