this post was submitted on 14 Jun 2023
20 points (100.0% liked)

Linux

5491 readers
655 users here now

A community for everything relating to the linux operating system

Also check out [email protected]

Original icon base courtesy of [email protected] and The GIMP

founded 2 years ago
MODERATORS
20
submitted 2 years ago* (last edited 2 years ago) by howarddo to c/linux
 

I think the main pain point of distro hopping is learning a new package manager, I discovered Nix a while ago, it works on every single OS, has the biggest package repo out there. I replaced Homebrew on my mac with it. If this piques your interest, give it a go. Later, you can integrate with Home-manager to manage all of your program config to have a reproducible dev environment on any machine, as described in the tutorial here.

The catch is it's really advanced and got steep learning curve. You can adopt gradually tho. Just get started with nix-shell and nix-env

top 20 comments
sorted by: hot top controversial new old
[–] JackbyDev 3 points 2 years ago (1 children)

Can you give an example of what installing a tool and using it looks like? Nix is very different from other tools I understand.

[–] howarddo 5 points 2 years ago

oh yeah, Nix is powerful and also has quite a steep learning curve compared to other tools, but you can adopt gradually, some utility of Nix I can list out here:

  • experimenting with packages with nix-shell when you are not sure if u want to install
  • use it just like other package managers like homebrew, yay, etc with nix-env (imperative way, not really recommended by the community)
  • manage the entire dev environment with home-manager and nix flake. If you use macOS or nixOS, you can even manage your OS settings (on macOS uses nix-darwin)
  • manage dev dependency on project level with direnv + nix. for example, you don't want to install python on your machine, but only want it active in the repo you're working on, u can declare it inside the repo

here is my tutorial a while ago, I still don't write the next part but this might be a good start for u. And here is my personal setup using nix and home-manager

[–] KindaABigDyl 3 points 2 years ago (1 children)

Isn't nix source-based thought? I don't want to compile all my software.

[–] howarddo 4 points 2 years ago

not if what you want to install is already cached on the server, which is mostly the case

[–] sisyphean 2 points 2 years ago (3 children)

I use dnf and flatpak on Fedora and I’m pretty satisfied. What is the killer feature of Nix that would make it worth learning how to use it?

[–] JackbyDev 6 points 2 years ago (1 children)

To add to the other comment, Nix really strives for true and actual reproducibility. Someone please correct me if I'm wrong, but my understanding is that even in builds it uses fake timestamps to ensure if a timestamp is in the resulting binary it doesn't mess up the hash of it. They really do try to go a step beyond others in the realm of reproducibility it seems.

[–] sisyphean 1 points 2 years ago

Thank you, you guys have convinced me to try it!

[–] howarddo 5 points 2 years ago* (last edited 2 years ago) (1 children)

the problem nix trying to solve is reproducible build, which means from a single config file you can migrate to any machine and have the same environment, auto install and dot files. While other package manager install in a imperative way, which means you have to call the install command on every package you need and you have to remember it. That's the basic difference. You can consider trying it if you see it's worth it. It's harder than any other package manager I know, but it solves a different problem.

[–] sisyphean 1 points 2 years ago

Thank you, this sounds extremely useful, I’ll definitely try Nix!

[–] Buttons 4 points 2 years ago (1 children)

A less theoretical advantage is that it can create the exact same environment on both Mac and Linux, and in neither case does it need to replace your primary package manager.

If the whole team is using nix, then the "setup" section of the readme just says "use nix-shell"[1] and that is more than enough for everyone.

[1]: I can't remember if nix-shell is the right command, or not, but in theory nix can create an exact environment on every machine with one command.

[–] sisyphean 2 points 2 years ago

Wow, that’s really useful. I’ll definitely look into Nix!

[–] msage 2 points 2 years ago (1 children)

So what's the catch? There usually is something not explained in the intro, that people should know beforehand.

[–] howarddo 2 points 2 years ago (1 children)

The catch is that it's hard, only if you want to use it at its max potential tho.

[–] msage 1 points 2 years ago

I use Gentoo on my desktop, so I can handle 'hard'.

If there is no catch, I might give it a try on my servers.

[–] benonions 2 points 2 years ago (1 children)

I love Nix even if the learning curve is STEEP.

Like you, I've replaced Homebrew with nix and home-manager.

I've also had a bit of fun spinning up full desktop environments with NixOS inside virtual machines and though it took far longer than I thought to get it going to start with, I've now got a good foundation and am super happy with it.

I'm working up to trying out nix-darwin. Think I'll start out with a MacOS VM first just in case I butcher it.

[–] howarddo 2 points 2 years ago

I would love to roll out my nix-darwin too, but I'm on a crappy 256gb macbook and xcode + android studio took most of it. Guess I have to experiment on the real desktop rather than macOS VM

[–] verstra 1 points 2 years ago (2 children)

Nice. Do you think it would be feasible to replace Nix-the-language with something more ... how do I say it ... conventional?

[–] howarddo 2 points 2 years ago (1 children)

I mostly copy from other people's config, not much learning at all. Heard that Guix is a good too if you only use linux, but it doesn't have nonfree softwares right?

[–] [email protected] 1 points 2 years ago

Guix indeed doesn't include nonfree software by default, but you can add the nonguix channel which does have it.

[–] Shareni 1 points 2 years ago

Guix uses guile scheme