Hacker News new | past | comments | ask | show | jobs | submit login

Nix plus homemanager plus direnv is the best solution I have found so far. Managing config (dotfiles) is only one part of the problem. You usually also need some way to install applications/tools ideally in a specific version. your config might not work as expected with a different version and you would have to remember what exactly you installed. As a developer using direnv will even allow you to use different versions of tools for different projects/ directories



I see a lot of people talk about homemanager, but I've been happy enough with the following in my configuration.nix:

    system.activationScripts = {
      dotfiles = ''
        cd /home/chriswarbo/.dotfiles || exit 1
        for X in *
        do
          [[ -h "/home/chriswarbo/.$X" ]] && continue
          [[ -e "/home/chriswarbo/.$X" ]] && {
            echo "WARNING: Found ~/.$X but it's not a symlink" 1>&2
            continue
          }
          (cd /home/chriswarbo && ln -s .dotfiles/"$X" ."$X")
        done
      '';
    };
I've been using NixOS for many years, but my dotfiles repo goes back even further ;)


For me, one plus of home-manager is that I can easily use it and share modules between NixOS and, say, Alpine + Nix


direnv is one of those things I've never found a use for because it's so simple to roll your own and because there are invariably situations I have that they don't handle well, my work needs don't map well to a directory based approach for example. My home implementation that's evolved over the years is about 60 lines of bash but a simple bare bones (and unsafe) one is as easy as:

  function cd { builtin cd "${@}"; [[ -f "$PWD/.env" ]] && source "$PWD/.env"; }
To me stow seems similar, I see little to no advantage over a script/makefile that creates the symlinks and you have the complexity of another tool to learn.


Can you describe more your setup? Some repo?


Heres home-manager repo you could try to learn from: https://simatime.com/git/ben/cfg.git/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: