Hacker News new | ask | show | jobs
by watusername 1258 days ago
Nice hack, but I still believe that home-manager [0] should be the way to go. It's the gateway drug to the Nix ecosystem and cleanly solves the composability problem which this "one-size-fits-all repo checked out to root" approach will have some trouble with.

[0] https://github.com/nix-community/home-manager

7 comments

Nix is like sailing from Oakland to San Francisco on an aircraft carrier for your daily commute.

Most stuff I care about factors out into .config which I turn into a git repo, push to GitHub and slap on a CI checks for secrets.

Most engineers don’t need to forge a demonic pact with the Nix gods who demand I upend and replace everything from my operating system to my wife.

95% of the time if I'm making nix a dependency it's just to install the correct version of python and poetry, then I let poetry handle the other dependencies. So it's totally possible to just use nix a little. My coworkers haven't even noticed the flake.nix in our repo, they just install those things by hand.

But then there's that 5% case where you do have to forge a demonic pact with the nix gods, and it's handy to have your summoning circle all warmed up and ready to go.

I had problems installing python dependencies with compiled library dependencies this way, eg pandas. Does that generally work for you?
Pandas is one of those for which poetry alone doesn't do the job. So I have nix install pandas alongside poetry so that when poetry tries to install pandas, the non-python dependencies are all lined up.

Here's a (too verbose, sorry) example: https://stackoverflow.com/a/74944857/1054322

It works well on all of my linux boxes. On my mac it takes forever because it wants to rebuild the linux universe. Given that the system architecture is a parameter, I think there should be a way to rewrite my flake (or update the nixpkgs numpy) to just rely on bsd tools in those cases, but I haven't found it yet.

That's what's holding me up from recommending it to my team. I'm happy to just use linux everywhere, but they aren't.

Learning Nix just do manage your dotfiles*, yes.

But, now that you're using Nix, ... you could use Nix to describe an OS setup, write Docker images, declare the tooling for a dev environment, etc.

Yes, in that it's military-grade technology that needs to be more accessible to the public. Otherwise I don't agree with your analogy.
Actual "military grade tech" assumes field service by minimally trained personnel and an efficient logistic chain of supply. This is is the opposite of Nix, which requires months of self-training futzing around with obscure commands and an obscurer language, backed by an out of date unsorted mound of documentation and recipes.
An F-18 is military-grade tech and no minimally trained personnel are getting anywhere near it. It's all just bad analogies is my point.
Well, the USS Hornet is stationed right there in Alameda, and it's not being used for anything else... :)
You win this thread.
For me the killer feature of home-manager versus other dotfiles managers is that it also installs any software your dotfiles depend on or assume to be present on the machine.
To me it is marking what is “garbage” vs what isn’t in the .config folder. I like to experiment on linux a lot, like switching to plasma and back to Gnome and it always leaves like 20 mostly-empty folders trashed. I can then just remove the folder and go on my way with home-manager.
If you're running NixOS there's an impermanence plugin that allows you to specify specific directories and files you need to persist outside of what NixOs/HM builds for you and then use a tmpfs in-memory partition for root and/or home. Then at boot you're loading up the NixOS/HM config and then the persistent files are symlinked or mounted to where they need to be, but otherwise you have a fresh system on each reboot. It's a bit painful and manual to figure out exactly what to keep (unless you just want to keep the entire .config, for instance, which I don't) but it's amazing to know that you can mess up your home directory as much as you want and then it'll automatically clean itself with a reboot.
It's definitely a gateway drug worth taking since Nix solves all kinds of other problems too.

Just don't expect to become an expert overnight, it takes a while to sink in (or it did for me).

It's sad though - there's almost nothing in Nix (in my experience) that has to be that difficult if you know any programming. It's a perfect storm of bad documentation, bad tooling and unintuitive UX.

I've been half tempted to try and bridge Nix with some simplified UX. Something resembling blasphemy but nonetheless focused on user experience above all else. At least doing that would be a natural project to learn Nix better, too heh.

(disclaimer: I use Nix[OS] on two machines and my macbook. I know it decently.. but far from where i'd expect given it's my primary OS and package manager)

I've just (literally a few hours ago) started a tool trying to follow those principles.

https://github.com/woile/npt

I still don't know if it's worth, I have to experiment a bit more with it.

I have to say I'm still struggling with the flake:/

That looks really cool, though for me it's the language and API that makes it awkward.

A really good LSP could do wonders for user experience.

Nix is a huge dependency though, in a lot of sense (have to learn a new programming language rather than invest in your git skills etc.). Even if you are mostly running nixos.
It's a one time investment though, and the payback is huge.
I'd like to agree, but my experience has been different. Basically...

1. invest a lot of time in learning nix (nixos in my case)

2. set up a system that works great

3. a year or two go by

4. need to make a change, modification, or set up another system

5. relearn everything from step 1

That said, I really do like the system. Just wish it were more user friendly and better documented.

Well, step 3 just shows how great it is.

But ideally no year will go by without using it, because you do install it to another system, tweak your home config, etc. The same way one doesn’t forget most of git, even though that one has some arcane UX.

If you are only changing your system once ever year or two, then perhaps it's not for you.

I'm running nix-build daily...

The payback isn't much compared to a regular git repo.

I love nixos but home-manager is just too much to force into all my other machines.

My current dotfile management makes heavy, near complete, usage of home-manager. If I want to do a redeployment I can simply install home-manager on a fresh installation, checkout my repository, and perform `nixos-rebuild switch`.
the read has “words of warning” almost immediately at the top about being familiar with nix first. it’s the gateway drug to nix?

bad docs and difficult to grok error messages seem to be a consistent theme that comes up learning nix.

You're only likely to screw things up once you start digging deeper into the Nix language/stdlib. I was put off by the warning at first as well, but it's honestly awesome having functional dotfiles that work reasonably consistently across NixOS (personal)/Ubuntu (work)/MacOS (work).

> bad docs

Yeah, pretty damned awful.

> error messages

That too.

I honestly think that inventing a language was a huge mistake. Guix took a much more sensible approach, but a libre kernel is unusable for 99.9999% of people.

Honestly, it really is not the language that’s the problem. While there are a few cases where it can trip you up at first, you wouldn’t be singing package descriptors even if it were Python — it simply has a business domain which is non-trivial. This non-triviality and organic growth show on the standard library of nix packages, but I fail to see how a lisp language or whatever be immune to it, besides having learned from some early abstractions mistakes.
Nix is building a package manager AND a programming language. Guix is building a package manager only. It's a resourcing thing.
And one might even argue the opposite, a DSL made for creating packages may well be better. Especially that plenty of package descriptions are basically reads like JSON.
Fair enough, that's a really good point.
It's kind of like LSD, your just gonna be unprepared the first time, and the second time...
Any home-manager users on NixOS here? Are there any killer features in home-manager for you? I tried home-manager for a bit, but just went back to plain NixOS after I couldn't find anything it did better than what I was already using ([1], [2]).

[1] https://gitlab.com/engmark/tilde

[2] https://gitlab.com/engmark/root

Easy integration between the two. I pass config from the system config to home config for some things and it’s quite seamless. Also one command to apply config for system and home is nice.
I use NixOS and do not use home-manager. I have synchthing managed by NixOS and it syncs all of my config and files between all my machines.

Btw, am I the only person annoyed at calling configuration files dotfiles? Not all hidden files/folders are configuration, and not all configuration files are hidden.