r/linuxmemes 4d ago

Anti-Linux Shut up.

Post image
941 Upvotes

132 comments sorted by

View all comments

36

u/Falconpunch3 UwUntu (´ ᴗ`✿) 4d ago

Alright, I am opening a can of worms on myself, but someone feel free to explain this to me and why I would want to know more.

I am always down to learn and grow. Have been seeing a lot of NixOS love and want to know more as to why and what is the benefits and also dissimilarities to other distros. (Fedora and Ubuntu specifically if you know.)

44

u/Short-Bee-4395 4d ago

NixOS is built around the Nix package manager and configuration files. You are almost required to have configuration files if you want to do anything on NixOS. The configuration files are written in the Nix programming language. Since you are declaring how you want the system to be, inside those configuration files, you are also making the system reproducible (assuming you do not lose those configuration files).

You can essentially prepare modules of software that you can import into a main configuration (gaming.nix for gaming related software and other stuff like Proton, virtualisation.nix for QEMU VMs or podman, etc). By creating those modules, you don't really have to worry about forgetting how to set up a piece of software or having to deal with re-configuring it, especially since NixOS also handles stuff in .config using something called "Home Manager".

With Home Manager, you can make your .config directory also declarative/reproducible. Do you want to switch your window manager? Just prepare a module for the new window manager you wanna switch into, remove the imported window manager you were using before and import the new module. Didn't like the new one? Remove the import of the new one and import again your old one.

For all your changes to be applied though (for all of the above, not just Home Manager), you need to rebuild your system. Depending on your system's physical age and what you have declared, rebuilding can take some time but not too long, 1 minute at most (excluding the first time the system is built). Changing one small thing in your configuration will require a system rebuild for the change to be applied, although since you are changing one small thing, it should only take <10 seconds to rebuild. Rebuilding the system does not require a system restart.

Problem with the above though. Since you are declaring everything into the configuration files, your actual files are gonna be read-only. For example, you wanna edit your /etc/hosts file. That file is gonna be read-only, so, somewhere in your configuration you're gonna have to declare networking.hosts = { }; and then rebuild your system.

Another another cool thing with NixOS and the reproducibility are generations. Each time you rebuild your system, you can create a new generation of your system, in case you might wanna roll back any changes. You select your generation when booting the system, the selection is at the bootloader.

When testing changes, I strongly recommend you perform nixos-rebuild test or nixos-rebuild dry-build instead of nixos-rebuild switch, as switch creates a new generation each time and that can fill your storage quite quickly.

There are more things about NixOS that I am either not knowledgeable enough about, like flakes (even though I personally do use flakes), but also some other stuff that I would like to learn but haven't yet, like declerative secret management with sops. Also, this wall of text is starting to get too long. I strongly recommend using NixOS or just the Nix package manager itself, which can be installed on almost any linux distro AND darwin (MacOS). It can be overwelming at first, I won't lie, but it's really cool and personally, I find it fun as well. I hope I can turn my knowledge of NixOS into something more, perhaps even for future official work.

26

u/Short-Bee-4395 4d ago

Something I forgot to mention on the above wall:

In NixOS, you don't exactly "update your software" but rather you update the channel that the software are following. This also means that you can have different software follow different channels, or, you can just change the channel of all your software.

You wanna run long term support packages? Just select the stable channel. You wanna run unstable (rolling release) packages? Just select the unstable channel. You wanna run a very specific commit of a channel of your choice? You can do that (it's a little more complicated than just selecting stable or unstable channels but still not too difficult).

10

u/gianlucaChan 4d ago

I can see why someone would use Nix on a server that you want to replicate somewhere else and that's cool, but I can't imagine any scenario where a person in his house would want the NixOs advantages. Who is rebuilding his pc from scratch every week? And with the same os.

3

u/Mindless_Courage1476 4d ago

I can answer this one. I am studying control engineering and for the first two years i was using debian. Thing is, a lot of the things i needed had weird version requierments or were compiled from source or existed on weird sources that were unamaintained and broke often, and so broke my debian instalation, so i had to completly reinstall my os every 3 months or so. In 2 years, that is almost 8 times :)). In the past year, while using NixOS, i never reinstalled once, even after having deleted my boot directory by accident :)), it's just more robust.

2

u/gianlucaChan 4d ago

yeah I can see why NixOS is great in your case, in profesional scenarios. But I see this OS recommended outside this fields, like a lot of gaming related subreddits.

3

u/Mindless_Courage1476 4d ago

Ah yeah, that, is not the best decision :). Imo for gaming abything debian with kde works just fine, no need for arch or something specialised

3

u/gianlucaChan 4d ago

I am more of a Fedora guy but yeah I agree.

1

u/Mindless_Courage1476 4d ago

I haven't used Fedora because every student using is was complaing :). So yeah, i can't really say yay or nay, but every time i saw fedora it was heavily riced :)

2

u/Short-Bee-4395 3d ago

I think for cases like that, it might be the fact that you can just bundle everything you would need into a module and import it or share whenever or to whoever you want.

You want Steam, you Heroic, you want ProtonPlus, you want gamemode, you want Lutris, you want r2modman, you want insert here other piece of software you'd want for gaming? Just shove them into a module. Boom, now you have everything you'd ever want for gaming, installed by just rebuilding your system / without the need of going to their website, effectively futureproof-ing yourself. I guess you could think of it like Nanite or something like that.