[Nix-dev] Nix as a dotfiles manager
Sergey Mironov
grrwlf at gmail.com
Tue Dec 2 11:55:44 CET 2014
> 2014-12-01 13:28 GMT+03:00 Sergey Mironov <grrwlf at gmail.com>:
>>
>> Hi. I've adopted the following compromise solution:
>> 1) Add the file include/templatecfg.nix with the following contents
>> { config, pkgs, ... } :
>>
>> {
>> environment.etc."template_XResources".source = ../cfg/Xresources;
>> environment.etc."template_vimrc".source = ../cfg/vimrc;
>> environment.etc."template_ssh_config".source = ../cfg/ssh_config;
>>
>> /* note, it should be possible to define inplace config here like
>> following:
>> environment.etc."template_ssh_config".source = textFile "dotbla" ''
>> [dotbla config contents]
>> '';
>> */
>> }
>>
>> 2) put template configs mentioned there in the ../cfg folder
>>
>> 3) For every machine, add
>>
>> require = [
>> ...
>> ./include/templatecfg.nix
>> ...];
>>
>> Now, every time I want to update my $HOME/.dotfiles I copy them from
>> /etc/template_* files. From the other side, sometimes I want to commit
>> my changed .dotfiles back into Nix repository. In this case I copy
>> them from $HOME to the $HOME/proj/mynixcfg/..../cfg/
>
> Your solution is really nice, but I want to automate it (esp the process of
> deploying my env on new machine), I can copy files now and manage them by
> git..
This is a tricky thing. I don't know what is your task exactly, but
typically, we deploy multy-user systems and we want supply users with
_default_ configs, for example, when we create their HOMEs. But after
that, users begin to manage their configs at their own. Managing
.dotfiles via git is one possible solution. Another solution - to
include cron task to copy /etc/template* to every user's HOME every
time system starts (for example). In this case you would have to
re-deploy whole system (make grub menu entry and so on) every time you
want to change your .bashrc.
More information about the nix-dev
mailing list