Live data from Hacker News

Home in Nix – dotfile management

hugoreeves.com

1–10 of 37 posts

Re: Home in Nix – dotfile management

#3

I just clone my dotfile repo from github into ~/darkrc and include the config files I want on each system, so my ~/.bashrc will have a "source $HOME/darkrc/bashrc" at the end, ~/.config/ranger/rc.conf will have "source ~/darkrc/ranger.conf", etc.

That's certainly one option. The unique thing about dotfiles is that everyone has a different 'best solution'. The setup outlined in my post has the advantage of being highly configurable and programmable. However, for some people it might make more sense to use a plain git repo with symlinks as installing Nix on all their devices could be a nonstarter. I'm curious, what do you use to manage tools that don't have a `source $SOME_PATH` option. Do you symlink?

Re: Home in Nix – dotfile management

#4
post #3

I just clone my dotfile repo from github into ~/darkrc and include the config files I want on each system, so my ~/.bashrc will have a "source $HOME/darkrc/bashrc" at the end, ~/.config/ranger/rc.conf will have "source ~/darkrc/ranger.conf", etc.

That's certainly one option. The unique thing about dotfiles is that everyone has a different 'best solution'. The setup outlined in my post has the advantage of being highly configurable and programmable. However, for some people it might make more sense to use a plain git repo with symlinks as installing Nix on all their devices could be a nonstarter. I'm curious, what do you use to manage tools that don't have a `…

I used to symlink and have a simple dotfiles repo, but this forces you to have exactly identical rc files. Different computers simply need different setups, so I started with ansible and a few playbooks running locally.

Re: Home in Nix – dotfile management

#6
post #4
post #3

Earlier quoted context omitted.

That's certainly one option. The unique thing about dotfiles is that everyone has a different 'best solution'. The setup outlined in my post has the advantage of being highly configurable and programmable. However, for some people it might make more sense to use a plain git repo with symlinks as installing Nix on all their devices could be a nonstarter. I'm curious, what do you use to manage tools that don't have a `…

I used to symlink and have a simple dotfiles repo, but this forces you to have exactly identical rc files. Different computers simply need different setups, so I started with ansible and a few playbooks running locally.

This was posted recently https://drewdevault.com/2019/12/30/dotfiles.html, but I actually liked the idea of using uname, hostname etc in constructing $PATH and even though I was already using git to track my dotfiles I adapted some parts of my setup like Drew describes and made $HOME a git repo itself ignoring everything by default. Works quite well across different OSs, machines and shells.

Re: Home in Nix – dotfile management

#8
I tried out Nix recently, with the intention of using it to get declarative management of my user account.

I discovered too late that Nix basically has no support for this.

While NixOS has some very nice features for declarative setup, user environment management boils down to terminal commands for "install package X, remove package Y".

The mentioned home-manager seems more of an awkward hack than a good solution in my view. It builds up a parallel package repository that you have to use besides the actual packages, and requires a lot of additional work if you want to customize something.

In my understanding (possibly incorrent?) it is also not actually immutable, but just dumps down files into $HOME, losing the most interesting aspect of Nix.

In the end I ditched it and stuck to my Ansible setup.

Nix is a great approach, and definitely worth a look, if you can stomach the other downsides (see below). But right now I would only recommend it for deterministic server builds or isolated dev environments, not for managing you main setup.

* Problems:

- There is plenty of documentation, but it is often incoherent, messy, missing important explanations, and it is generally very awkward to get a good insight and understanding of how all the parts fit together.

- The language... it is full of confusing oddities; clearly something that has grown peace by piece. Switching to something more coherent like Gluon (also functional, https://github.com/gluon-lang/gluon) would seem like a better approach to me.

- Packages: The quality can be very hit and miss. I discovered several that are written poorly. Plenty are also outdated/unmaintained. But: considering the niche nature of Nix, the amount of packages is actually quite impressive.

Re: Home in Nix – dotfile management

#9
post #7

Would prefer GNU stow for simplicity. https://www.gnu.org/software/stow/

GNU Stow is _great_ for this. I have the following in my dotfiles dir:

    [~/code/dotfiles]$ tree -a -R -L 2
    ├── aws
    │   └── .aws
    ├── git
    │   ├── .gitconfig
    │   └── .gitignore_global
    ├── .gitignore
    ├── .gitmodules
    ├── gpg
    │   └── .gnupg
    ├── README
    ├── ssh
    │   └── .ssh
    ├── tmux
    │   ├── .tmux
    │   └── .tmux.conf
    ├── vim
    │   ├── .viminfo
    │   └── .vimrc
    └── zsh
        ├── .oh-my-zsh
        └── .zshrc
I can then stow any of these into my home dir with:

    $cd ~/code/dotfiles
    $ stow -t $HOME git
That sets up a link from all the files in my home dir like:

    .gitconfig -> code/dotfiles/git/.gitconfig

Re: Home in Nix – dotfile management

#10
post #7

Would prefer GNU stow for simplicity. https://www.gnu.org/software/stow/

I've looked at and read about other's experiences with stow in the past. I'm uncertain about this so please correct me where I am wrong, but the issues I see with stow are: 1. It's somewhat dated/may have a tail of legacy features 2. I'm unsure of it's value beyond of what can be provided via the Git Bare Repo solution linked in the intro of my post. 3. More importantly, it's not a programmable solution where you can override default files based on the current system. The main value proposition I see in my system is that I can define a single default configuration for, say, my terminal Alacritty, and override the configuration where necessary based on either my user, machine or role. Nix is a programming language, so I essentially have my system configuration managed via a programming language and can control things with a great level of detail.
Post reply on HN