[Nix-dev] Nix as a dotfiles manager
Arseniy Seroka
ars.seroka at gmail.com
Tue Dec 2 00:43:15 CET 2014
>
> On Sun, Nov 30, 2014 at 9:29 PM, Arseniy Seroka <ars.seroka at gmail.com>
> wrote:
> > Hello!
> > I want to do smth like
> > `if networking.name = "foo"
> > then writeFile "/home/user/.dorfile"
> > else if networking.name = "bar" then ...`.
> What do you mean by networking.name, are you referring to the NixOS
> option?
Yes. (but it doesn't matter indeed).
> And what is a best way to do it?
If you are under NixOS, then you should use the activation script to
> copy it to the home directory of the user. Nix is deliberately not
> capable of writing out-side the Nix store, but we can create & execute
> scripts which are sym-linking the files of the Nix store.
Indeed I mean NixOS instead of just Nix.
> I thought smth like: now we are making pkgs and making symlinks to their
> > executable to ls `~/.nix-profile/bin/`.
> > Maybe there is a way for some derivation set the "output path" as a `~/`
> and
> > do smth like (write it in a ~/.nixpkgs/config.nix):
> No, the ~/ is replaced while building the derivations, such as we do
> not pollute user environment, and such that builds can be reproduced
> when multiple users are requesting the same derivation.
So can you tell me how does Nix and Nixos know that they have to link
binaries to a `~/.nix-profile/bin/` if we are using `nix-env -i`?
May be we have to dig here to replace output path for configs to a user's
directory and produce derivations with text files?
SO
> > `configs = buildConfigEnv "~/" [
> > { name = ".zshrc"; contents = ''#zshrc config''
> > }
> > ]`
>
is showing smth like this...
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..
--
Sincerely,
Arseniy Seroka
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20141202/4799d978/attachment.html
More information about the nix-dev
mailing list