13

I heard a lot about the concepts of nix and NixOS and I'd love to try it.

After installing the VirtualBox demo, I keep getting stuck with every tiny step I take, though.

So I was wondering if there are any tutorials for beginners that you can recommend?

I couldn't find anything on the internet - everything that looks like a tutorial presumes a lot of things everybody seems to know about nix, so no need to explain those.

Where can I find those explanations to make the first baby steps with NixOS?

To put it in other words: Where is NixOS for dummies?

all 14 comments
sorted by: hot top controversial new old
[-] sajran@lemmy.ml 5 points 6 months ago* (last edited 6 months ago)

I've been playing with NixOS in spare time for a few weeks now and I'm afraid I don't have a very good news for you. It looks like the learning curve is just very steep. It took me quite a lot of time to get to the point where I have any idea what I'm doing. Some beginner friendly resources which helped me:

In general, I recommend checking out people's configs on GitHub. You can learn a lot by example.

[-] silmaril@discuss.tchncs.de 2 points 6 months ago

Thank you very much for those links!

Generally I don't like video tutorials much - I prefer reading things in my own speed and being able to copy & paste stuff.
But only looking at the titles of those videos sounds promising enough to give them a try :-)
(I didn't yet have the time to watch any of them.)

One aspect I find interesting:

One look at the Misterio77 configs shows that the concept of flakes seems to be important. I have no idea what they are, but I can see that both youtubers have something about flakes as the second video in their NixOS playlists - looks like I should better learn about this concept soon :-)

[-] silmaril@discuss.tchncs.de 2 points 6 months ago

Oh! Just found out that LibrePheonix accompanies each video with a blog article - that's nice ๐Ÿ™‚

https://librephoenix.com/blog.html

[-] sloppy_diffuser@sh.itjust.works 2 points 6 months ago

Once you have some foundational knowledge, I find more answers searching github with language:nix <some terms>. Usually I can find a few repos with an adjacent enough solution to deconstruct and apply to my setup.

[-] ComradeKhoumrag@infosec.pub 2 points 6 months ago

I'm using NixOS partly as a dev machine, but mostly for consumer OS stuff like gaming, YouTube, social media...

What are you trying to use it for? From the consumer perspective, I feel like modifying configuration.nix would be the majority of what I need. It's like ninite if you've used that to setup a Windows machine, but it can be preloaded on your OS and you can configure everything, not just which programs are installed

If you're trying to setup dev environments, I think what gets weird is how many ways there are to do similar things, like nix develop, nix build, nix shell...

[-] silmaril@discuss.tchncs.de 2 points 6 months ago

Currently I am playing around in a virtual machine to get to know NixOS and find out what I can do with it.

I'd like to set up a usable everyday desktop configuration with "everything".

This includes typical desktop applications like Firefox, Thunderbird, LibreOffice ... development tools like Git, PyCharm, VS Code, ... all those little things I need to work productively like Nextcloud desktop client, KeePassXC, Zim and many more.

And I'd like to have zsh as my default shell with my own custom theme and some dotfiles for different applications that currently reside in a git repo that I clone to every machine I use.

I know this is a lot and I don't expect to get this all up and running in an afternoon.

It's just that I find it very hard to find the next bit of information I need. For example I found snippets to put into my configuration.nix long before I found out where to find this file (/etc/nixos/configuration.nix).

From the answers so far I gather that there really is no (official or unofficial) documentation to tell NixOs newbies how to start, so everyone just makes do with the things they find.

So I think I'll just fight my way through this jungle, too ;-)
The price that's waiting at the other and seems to be totally worth it!

If anyone has valuable tips or links to help me achieve something from the things I listed, those would be very much appreciated! :-)

[-] ComradeKhoumrag@infosec.pub 3 points 6 months ago* (last edited 6 months ago)

Yea it's definitely a jungle haha, it also seems they're changing things up a bit with where the most recent docs might be hosted

https://search.nixos.org/

so, if you searched for vscode in that link, then click the "NixOS Configuration" button, you can see

  environment.systemPackages = [
    pkgs.vscode
  ];

or if you're using the with convention to factor out the pkgs object/contextual keyword(not sure if that's the right name)

  environment.systemPackages = with pkgs; [
    vscode
  ];

for zsh, just having this in your configuration.nix should work https://nixos.wiki/wiki/Command_Shell

programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;

Again, these values should be inserted after the function definition of your configuration.nix

{ config, pkgs, ...}:
{
   # Things get inserted here typically
   imports = [ ./hardware-configuration.nix];
   environment.systemPackages = [pkgs.vscode];
}

for example.

Something I've noticed from developing on nix, When the headaches of nix appear, the solution might be harder, but I usually end up with a better solution than what I was going for before. Some examples:

  • My resume is compiled in Latex. I tried the pdflatex package in nix but it gave rendering issues. Then the nix community recommended tectonic and i'm getting better compilation times, logging, clean up...

  • PIP is a garbage package manager, and it's garbageness sometimes makes native python development a headache in nixos. However, using poetry2nix, not only could I define development environments, it was also ready for packaging on PIP

Sometimes you might want to separate some parts of your configuration away from your global system config at /etc/nixos/configuration.nix. That's nix-shell, nix-develop, nix-build, and flakes are for. I'm not a pro at flakes yet, but I think I got the gist, here's an example of when I wish I could have used a flake:

I use discord but discord itself is garbage. Vesktop is a better 3rd party client for discord. Unfortunately, I had to remove it from my configuration.nix the last few weeks because one of its dependencies wasn't packaged right, causing my entire system to not build. If I had used a flake, I could have isolated that dependency from the rest of my build, while still tracking its integration with my system. I believe this could have allowed me to update the rest of my system, while still defining the errenous app as part of my system. Flakes are supposed to be more reproducible as well, since they require sha256 git commits, whereas other package managers only ask for a subjective version number

There's a lot to learn with nix but even if I don't stick with it long term I feel like It's making me a smarter software engineer since a declarative/functional paradigm tends to match the natural language more. It also is the most restrictive design paradigm, which means it's brief but so simple it can be hard to understand as a consequence. Since it's so restrictive, it's also a subset of all other paradigms. You declare what you want, ideally, you don't have to set anything up. I never had an easier time getting cuda drivers for ML Training setup than on NixOS because of this

Something I enjoyed doing, was setting up my user profile to let me ssh in only with whitelisted ssh keys, as well as setting up a systemd script to handle some start up routines on my OS. I think that can be a gentle introduction to how you can configure other parts of your operating system. I'm going to try and set up a CI/CD/CT pipeline with it next I believe

Edit: The next thing I need to do as well, is consolidate my user configs with the home manager functionality. I use a KVantum Theme engine on top of plasma, and while those apps are installed in my system, the configuration of which theme to automatically load should be integrated with the text config aspects of nixos. Currently, I "Imperatively" configured those by "Opening the app and clicking", which will get erased/not be reproducible if I ever rebuild my nixos on a new computer

Another funny thing with functional programming... sometimes the fix is as simple as

sound.enable = true;

Even though I had pipewire enabled as a service and everything, that one line needed to be there haha

[-] sloppy_diffuser@sh.itjust.works 2 points 6 months ago

If I had used a flake, I could have isolated that dependency from the rest of my build, while still tracking its integration with my system.

I have to do this weekly with my bleeding edge Hyprland setup.

I've been using nvfetcher to feed my nightlies addiction for software that doesn't have a flake.

Only major hiccup I had was pulling a few packages from nixpkgs master due to a bug that got introduced in unstable for electron apps before it hit cachix. Wasn't expecting it to take a day to compile everything that depended on it.

10/10 would highly recommend flakes.

[-] Vilian@lemmy.ca 2 points 6 months ago

i installed nix in my fedora and i can say that in this case just jumping in it is easier because you can search about the errors imo

[-] silmaril@discuss.tchncs.de 1 points 6 months ago

I know what you mean - the problem with this approach is that things might work, but I am using it not in the way it's intended, because I didn't understand the underlying concepts.. But I cannot search for concepts of which I don't know they exist...

[-] sloppy_diffuser@sh.itjust.works 2 points 6 months ago

but I am using it not in the way it's intended

This is absolutely intended. Nix is a programming language, package manager, and operating system.

Nix the package manager is intended to be used on nixos and non-nixos operating systems. It has first party support for Darwin (macOS).

My nixos build is not daily driver ready, so I'm still on Ubuntu for my productivity systems. The majority of the Ubuntu apps I use are managed via nix using home manager at this point. These share the same configurations with my nixos systems.

It is relatively low risk* since nix installs everything in /nix/store and sets up some env vars and user systemd services with symlinks to map to there. If I install Firefox with nix, the Ubuntu version is still there untouched. My PATH just hits nix first before the system. You have to change like one file if I'm remembering correctly after uninstalling if you want to back out which is the trigger for a nix package to come before a native package.

  • If you dip into declarative app configs (zsh, fish, nvim, etc.) you can absolutely lose the original. I tracked all that in a dotfiles repo before nix personally. Just have backups and start small.
[-] silmaril@discuss.tchncs.de 2 points 6 months ago

That sounds like something I should try, too.

Currently I'm using Linux Mint and I also have a dotfiles repo, so that sounds quite similar to your case.

[-] Vilian@lemmy.ca 1 points 6 months ago

lol true, i read a comment that explained it as " nix is for people who need to install different apps all the time, especially programmers who need to test with every different lybrary etc, or people who need to have their system writen in a config file, to deploy it to others computers etc" so for me this isn't viable, i only use nix for a few packages that i want to keep up to day, or packages that fedora don't have, that's way i went with fedora atomic and nix, a stable system but without needing the entire nixOS

this post was submitted on 11 Apr 2024
13 points (93.3% liked)

NixOS

753 readers
1 users here now

NixOS is a Linux distribution built on top of the Nix package manager. Its declarative configuration allows reliable system upgrades via several official channels of stability and size.

This community discusses NixOS, Nix, and everything related.

founded 1 year ago
MODERATORS