How to install nix cleanly?

Hello all.

I want to install nix, but the quick install method in Download Nix / NixOS | Nix & NixOS is a bit ugly.

I couldn’t find any initiatives to package this into Fedora, which surprised me, as nix is an amazing technology, helpful specially on workstations (ahem).

Is there a way to install it with the usual ergonomics of an rpm? Is there any initiative to package it into Fedora?

Thanks!

2 Likes

What is your system? What Fedora?
Ugly, what do you mean?

There are some copr’s.

That being said, I think the script from the nix site is pretty clean. nix lives in it’s own space so it should be fine.

2 Likes

I’m on fedora silverblue 35.

By “ugly” I mean it’s not a rpm package, with automatic updates and so on.

Also I couldn’t find any copr.

2 Likes

Some software is only ‘ugly’. Most of them will warn you to manually update.

In your case, you wouldn’t want to push nix into an overlay. Isn’t it actually far better for it not to be a package on Silverblue?

It has been a while since I ran nix outside of nixos but aren’t the nix commands updated by nix itself? You should already be using nix to update all the software you install with nix.

http://nix-community.github.io/nix-installers

2 Likes

Yes, actually I opened fix: make nix work out of the box on rpm-ostree by yajo · Pull Request #8 · nix-community/nix-installers · GitHub to make Nix properly installable inside rpm-ostree distros, such as Silverblue.

1 Like

that sounds like a good first step!

So one could layer the RPM.

The problem would be that nix wants to write to /nix which is immutable. But you could mount /var/nix to that diretory maybe? I am not sure if this is possible. Maybe a flag for nix to use a different directory would be a better option

Symlink would be more inline with Silverblue I would think anyway.

Just curious, what is your use case for Nix which you can’t do or isn’t as good on Fedora? Also what makes you use Fedora as the base OS and not just go full NixOS?

Honest questions coming from a long-time Fedora user who generally sticks to defaults and/or prescribed workflows, would like to understand the pros and cons from another Fedora user’s perspective.

It’s better to use a bind mount: nix-store --query - Nix Reference Manual

It’s the definition of reproducibility.

OSTree (the technology that powers Fedora Silverblue), just like Docker, Flatpak or Podman, lets you reproduce the outcome of a build. But if you build a 2nd time, you can get a different output.

Nix lets you reproduce the full building process. No matter how many times you build, you’ll get the same result.

Thus, when you package anything with nix, you’re sure that it is exactly what you meant. When you share a devshell with your colleagues, you know it’ll work exactly like locally. When a system update breaks one package build, you can pin that old build while still keeping the rest of the system updated.

Besides, you can have multiple versions of the same library without any conflicts, and each package can use the one supported by it.

NixOS was very influential to the OSTree project, but they still decided to create OSTree because Nix has its downsides too. It’s basically 2 approaches to the same problem, each one with their tradeoffs.

I’ve been a long time Fedora user, and it’s easier to start using nix by just installing the package manager on top of your current known system.

At some point, I plan to switch to NixOS if it proves to be at least as useful as Fedora for a workstation.

I use NixOS on servers these days, and I’m probably never looking back. It’s absolutely awesome.

Contradicting myself, these days a new nix installer exists, with OSTree distro support: GitHub - DeterminateSystems/nix-installer: Install Nix and flakes with the fast and reliable Determinate Nix Installer, with over a million installs.

Once you install Nix, it updates itself. Thus, it’s not very useful to install it through an RPM (outside of the fact that Silverblue users feel that’s easier for them, like myself in the past).

1 Like

Hello @yajo ,
Yes, a bind mount does make more sense now that you mention it.
I use GuixSD on one of my Lenovo’s, and it is declarative and reproducible as well, and is (generally) based on the work done on NixOS. I ran Guix (the package manager) on my workstation before I ran Silverblue/Fedora Atomic in fact.

Silverblue is officially supported by DeterminateSystems Nix installer. It is a better and a “cleaner” Nix installer that does not require you to workaround rpm-ostree or SELinux.

1 Like

a ublue project that allows nix! Sounds crazy!

2 Likes