[Nix-dev] Using Nix to manage dotfiles

Thomas Bereknyei tomberek at gmail.com
Tue Feb 11 03:38:01 CET 2014


This is not what you are looking for, but here is how I manage my dotfiles.
 I place my default into /etc/nixos and create symlinks to my users.

let
    storeFile = fileSrc : builtins.toFile (baseNameOf fileSrc)
(builtins.readFile fileSrc);

    vimrcPath = storeFile "/etc/nixos/vimrc";
    i3Path = storeFile "/etc/nixos/i3/i3config";
    i3SPath = storeFile "/etc/nixos/i3/i3configstatus";
    ohmyzshPath = "/etc/nixos/oh-my-zsh";

    createUsers = names : pkgs.lib.listToAttrs (builtins.map (name:
        {inherit name; value = {createUser = true;
                                createHome = true;
                                home = "/home/${name}";
                                useDefaultShell = true ;
                                isSystemUser = false;
        };}) names);

    setupUsers = names : pkgs.lib.listToAttrs (builtins.map (name:
{
inherit name;
value = ''
ln -f -s ${vimrcPath} /home/${name}/.vimrc
mkdir -p /home/${name}/.i3
chown ${name} /home/${name}/.i3
ln -f -s ${i3Path}  /home/${name}/.i3/config
ln -f -s ${i3SPath} /home/${name}/.i3/configstatus
ln -f -s ${ohmyzshPath} /home/${name}/.oh-my-zsh
        '';}) names );

in
{
  system.activationScripts = setupUsers [ "user1" "user2" "user3" ];



On Mon, Feb 10, 2014 at 9:00 PM, PkmX <pkmx.tw at gmail.com> wrote:

> Hi all,
>
> I wonder if anyone have experimented with using Nix to generate
> dotfiles (.zshrc, .vimrc, etc) in a manner similar to NixOS. For
> example, it would be cool if `vim = { enable = true; tabstop = 8;
> plugins = [ pkgs.vim.powerline <...> ]; };` will install vim, pull in
> plugins (and their dependencies, if any), generate .vimrc and put them
> in the correct locations, and that being able to specify any packages
> that my configuration/scripts depend on, which are installed
> automatically to make sure my scripts always work. This combined with
> systemd user services[1] should allow users to easily build and manage
> their environments in a single, consistent and elegant way.
>
> Does anybody have any experience on this or examples to share?
>
> [1] https://github.com/NixOS/nixpkgs/issues/1689
>
> --
> PkmX
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20140210/ff3f6aed/attachment-0001.html 


More information about the nix-dev mailing list