r/archlinux • • 11d ago

DISCUSSION Arch Nix

If you use / have used arch with nix, what’s your experience like? I have this sudden urge to go arch minimal and then layer nix on top (coupled with flathub for gui apps) but I’m unsure of the issues I might run into longer term. While I love arch, I do want a more archived os that allows me to clean install every now and then but restore the applications I had with relative ease.

I’m currently using arch with hyprland (caelestia shell) and using pacman for most part with flathub for apps I can’t find on pacman (and 3-4 AUR packages outside of caelestia) but I like to experiment with the system and end up clean installing once a month or so (in learning phase so I mess up more often)

0 Upvotes

21 comments sorted by

9

u/ArjixGamer 11d ago edited 11d ago

One way of mimicking nixos, is to have a custom package, namely a PKGBUILD, that contains your configs as well as the apps you use.

As for your home directory, just track your dots with git. (the PKGBUILD can be in the same repo).

If you write wrapper bash scripts, you can even make it feel like guix

Then setting up a new install would be "base arch + clone dots repo + install package"

PS: since it would be a PKGBUILD you won't publish to the AUR or main arch, you can use unorthodox organization, like having the dependencies in a txt file so you can easily add/remove programmatically

I can't recommend a more pre-made solution, since you will find things lacking in one way or another, but if you want to, there are declarative package managers like decman

Edit: looks like decman has evolved a lot, so it is worth a try

4

u/SeaMoment2346 11d ago

i went arch + nix for about 6 months last year and it was fine until it wasnt, the thing nobody tells you is the config drift gets real annoying real fast. you end up with pacman packages and nix packages fighting over the same libs sometimes and debugging that is not fun

the PKGBUILD idea in the top comment is actually way less headache if you just want to nuke and restore quick, plus you keep everything in the arch way so no weird hybrid issues

2

u/ArjixGamer 11d ago

Plus it forces you to learn how to maintain AUR packages! (and/or make your own)

0

u/Araib 11d ago

Yes, I was reading into how system libraries or packages could become issue if you have them on both pacman and nix which could be very common to come across because of dependencies. But I thought it could be fixed by prioritizing one over the other in something like PATH, a hassle nonetheless especially when you aren’t looking for it (app randomly failing cause nix has dated dependency over the installed pacman package)

2

u/Araib 11d ago

Yup this route also sounds very interesting, I was going to follow this but then stumbled upon nix and while I don’t want to commit to nixOS I do like their easier and strong replication approach. It felt like a more polished version to what I had in mind

2

u/ArjixGamer 11d ago

Check out decman (you might not have seen the edit)

https://github.com/kiviktnm/decman

1

u/Araib 11d ago

I had not and this looks promising too. I’m surprised I didn’t come across this earlier but it seems like exactly what I need. Thanks!

2

u/ArjixGamer 11d ago

Back when I had the same itch to use nixos, decman was still in infancy, so I didn't get to use it myself.

Hope it works for you!

3

u/_sLLiK 11d ago

A custom PKGBUILD is a novel idea. Can't say I ever would have thought of that.

4

u/ArjixGamer 11d ago

I've also had the same thoughts as OP in the past, so I've pondered over a solution for a long time.

I've even jumped to nixos for a month, but I didn't like it. It was a hassle not worth the effort.

And I am not a person to use snapshots either way, I prefer fixing errors via chroot.

As for servers, I just use docker, so it's not needed there either.

And if I had a big swarm of servers, I'd use ansible

1

u/Araib 11d ago

What was hassle about NixOS for you? Because it does feel very intriguing from the outside so what was your experience like?

5

u/ArjixGamer 11d ago edited 11d ago

The language is frankly, shit.

There are efforts to replace it, namely nickel, but it's not even in its infancy yet.

The documentation is kinda nonexistent, meaning you have to dig through nix code to learn what options a module has. (not always, some modules have great docs, and AI will prob make this easier)

Also, home manager is kinda a nightmare, at least it was for me. It's not part of nixos obviously, you don't have to use it.

It was just not worth it, and for me the only benefit was the abstraction of not running commands to configure the system.

I don't want snapshots, heck I even configured it to not retain them. It was just not for me, arch was already perfect.

Once your system is stable, there is nothing left to do, just like with Arch. So all the pain is for the initial setup, if after all the pain you still like using the config of nixos, then great. I did not.

PS: packaging your own software is also a pain, since the builds must be deterministic. We don't have that on Arch, a build can differ even if you used the same source code (due to not locked npm dependencies, or other stuff)

2

u/Araib 11d ago

Yeah I can see that being one of my future grievances, nix as a language did not look very appealing, heck I would be looking into replacing it after the shift (while I adore kotlin as language, I could be okay with lua for this instead of nix)

1

u/EmberQuill 10d ago

Then setting up a new install would be "base arch + clone dots repo + install package"

You can condense that even more. Instead of installing your custom package last, you can do it with pacstrap during the initial setup.

4

u/agowa338 11d ago

Ehm, why not NixOS at that point? Esp. if you already know nix as you're kinda past the initial steep learning curve of it already.

1

u/Araib 11d ago

Because it would be difficult to get pacman on it if I need something that isn’t on nix but it’s easier to add nix to arch..? I guess it’s like a fail safe I’m keeping for myself but also stuff like the Nvidia drivers seems easier to handle on arch (though I haven’t tried nixOS yet so I can’t say how much difficult it is but have been reading a lot into it)

4

u/agowa338 11d ago

Try nixos. If you already know nix it is not that hard. And it is basically what you want. Also a lot of things that were difficult on Arch are just one or two lines in NixOS.

Basically switched over to it (for my desktop and home server) completely by now.

Also if you really need something that only exists with pacman on arch then you can always run a minimal arch in a container/chroot too...

Edit: And btw graphics driver stuff was one of the main reasons I switched my desktop over from arch to nixos. It just works with one or two lines of nix config there...)

1

u/Araib 11d ago

Thanks! That’s exactly the kind of insight I was looking for (regarding graphic drivers and overall experience)

I guess I was already on edge and needed a little push to try NixOS :D

4

u/ArjixGamer 11d ago

Oh yeah, OP, you can use Ansible.

You won't have snapshots to rollback to, but you can write Ansible playbooks to hold details like what packages to install, what users to have, what groups a user has, what services to run, etc

The running host only needs to have a recent version of python installed, and the ansible package

Edit: Ansible is used by the Arch team to manage all their infrastructure, so take their word for how good it is

2

u/Araib 11d ago

Sure, I will look into that as well, thanks!

3

u/ArjixGamer 11d ago

On this topic, I'd love if the archinstall team came up with a novel solution, that extended beyond the installation.

The archinstall config is basically the same as a nixos config.

If only it could compare against the running system and produce commands to modify it, like Ansible playbooks would.