Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Currently, Nix way of handling dotfiles is "home-manager". Personally, I'm not convinced to translate all my random dotfiles to the format acceptable by home-manager because I wouldn't be able to use them in a non-nixos distro or a future home-manager replacement itself.


1. home-manager is perfectly usable on any linux distro, that's in fact how the eventual transition to nixos started for me -- by porting my home config (on ubuntu, at the time) to home-manager. in fact I still keep my os-config and home-config repos separate, so my home config should still on non-nixos if the need arises

2. you don't need to "translate" any existing config files, it's perfectly fine to use them as-is.


I see. So there's a solution for dot files, if a bit too involved. Currently for a low effort approach when backing up something that I know requires a bit of reparse, I use ansible templates, which basically replaces 1 string with another in a file. So far this always worked.

What about application files? I.e. backing-up/restoring firefox. In it's simplest form it's copying ~/.mozilla which I appreciate is no different than copying a dot file. Does nix have a way to restore app artifacts?


Imo Home Manager isn't really about dotfiles. It's a NixOS-like module system for configuration unprivileged programs and services. You could use it, for example, to install and configure systemd user services for Emacs to run as a daemon, and for gpg-agent to run and work as your SSH agent. It lets you bundle specific versions of programs (with patches or configuration changes) in a declarative, reproducible way on non-NixOS Linux distributions, and if you incorporate it into your dotfiles it lets them become more reliable and comprehensive in that way. It also includes features for directly managing dotfiles, but if you're happy with your current dotfiles management system, you can leverage Home Manager to portably configure services without using it for directly managing all your dotfiles.

> Does nix have a way to restore app artifacts?

Not really. The Nix store is read-only, so if your dotfiles are in the Nix store, running applications can't write to them. There's a lot of stuff in ~/.mozilla that Firefox expects to write to during operation. There are aspects of Firefox that you can configure in Nixpkgs, including bundling extensions and setting defaults, but ~/.mozilla is not like ~/.vimrc, so it's not suitable to generation by Nix in the same way.


BTW, there is a Firefox module in Home Manager for those who want a customizable Firefox. Like, I set my custom `about:config` flags there and every time I reinstall my system I am sure that I didn't forget that random config to enable hardware acceleration again. You can also manage extensions with it, but for this part I prefer to use Firefox Sync itself.

At least for me, this is even better than backup/restore. Generally I don't want to preserve cache or cookies between installations, I just want my config there.


> At least for me, this is even better than backup/restore. Generally I don't want to preserve cache or cookies between installations, I just want my config there.

Yeah, I agree. NixOS even includes a module for easily hosting your own Firefox Sync server, too! So I guess in terms of use cases the solution is actually more or less complete.




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

Search: