[Nix-dev] /etc/nixos/configuration.nix vs ~/.nixpkgs/config.nix

Jonathan Glines auntieneo at gmail.com
Mon Jun 29 18:38:12 CEST 2015


2015-06-29 8:20 GMT-06:00 Kamil Chmielewski <kamil.chm at gmail.com>:
> Hi,
>
> I'm trying to setup NixOS on my laptop and I feel really confused with this
> 2 config files.
> I would like to have base system configuration like hardware and system
> services in /etc/nixos and other software and user configuration in
> ~/.nixpkgs.
> I'm stuck on custom gtk theme now. I don't want to install my gtk theme
> system wide, but in my user scope only. I searched everywhere and I can't
> find an example ~/.nixpkgs that will setup my env analogous to Deian conf:
> 1. gtk theme in ~/.themes
> 2. custom ~/.gtkrc-2.0
>
> I had a repo of dotiles for debian with many other things like .gitconfig,
> .vimrc, .profile ....
> How to rewrite it to NixOS?

Like Eelco said, there's no proper support for dotfiles in home
directories *yet*.

But I've been using system.activationScripts as a hack to get it
working anyway. Inside my configuration.nix looks something like this:

 system.activationScripts =
  {
    # Configure various dotfiles.
    dotfiles = stringAfter [ "users" ]
    ''
      cd /home/auntieneo
      ln -fs ${./dotfiles/vimrc} .vimrc
    '';
  };

What happens here is NixOS tells systemd to run an activation script
on every boot (and every time you nixos-rebuild switch) after it
creates the user accounts. It's a bash script with Nix expressions, so
there's the potential to do a lot of very clever things. Dotfiles show
up as read-only symlinks in my home directory, which works very well
for 99% of programs.

Unfortunately, this is inside configuration.nix and not ~/.nixpkgs.
I'm not too happy about that, but when NixOS gets around to managing
user dotfiles I'm sure that will change.

My dotfiles can be found on github (warning: very messy):
https://github.com/auntieNeo/nixrc/blob/dc744edd/configuration-common.nix#L60-L114

I'm pretty sure a few other people do this the same way, since I
originally discovered this method on this mailing list.

Regards,
Jonathan


More information about the nix-dev mailing list