New User: Starting out direction(opinions)

Hi there, I’ve been a long time Linux user, but I’m looking at moving over my secondary system (laptop) to use NixOS. The intent is to move everything in this direction once I feel comfortable enough with NixOS.

My current use case is a workstation (gnome based) that I use for working in the Kubernetes ecosystem, as well as general computing use. Chrome, vscode, and other various cli tools.

Now I have been reading the documentation, and it feels like there’s many different directions I can go to get started.

What I’m looking for is an experienced users opinion around the following (so I can pick the right direction, and read the appropriate documentation.):

  • with regards to installation, do most people use the ISO, or the minimal installation and then layer up super custom? I’m a fan of the sane out of the box settings. And I don’t necessarily need to tweak out everything. I think I ultimately want to stick close to the default installation from the ISO, plus my own settings and tweaks.
  • and if using the ISO, is there a way to automate the installation itself? Meaning all of the questions that you traditionally see through the GUI installer. What I suspect is there is a way to pass in a configuration.nix.
  • if the path to installation automation is to use the minimal set up, plus a configuration.nix, is there a document somewhere that covers this use case, as well as getting as close as possible to the default ISO installation?
  • i’ve seen mentions that people are using home manager. But just for context, I want to try to use nix‘s itself as much as possible.
  • i’ve seen a mention of flakes. Is this something I should tackle right from the beginning?
  • I suspect I’m gonna have to look at package building, just in case I cannot find what I need. This also leads me to wonder, where are people pulling packages from? And what I mean by that is does the Nix ecosystem traditionally use a lot of third parties, or are they bundled up and more of a central location? That the community considers trustworthy.

I guess if I was to summarize it all, with the intent of ultimately ending up at a solid vanilla laptop workstation, what is the methodology best suited? I figure I’m at a Greenfield type situation as I’m just beginning to learn. All I’m really trying to do is expedite the decision tree as to which way to go. Not necessarily looking for someone to summarize the docs. I’m more than willing to go and read. Although any useful links are appreciated.

I appreciate everyone’s time.

2 Likes

One other thing I just noticed. I had done an installation on my laptop with the ISO. And manually clicked through the installation questions. Now looking at the configuration on the system, I assume I can throw that into version control and use it on my next installation. And if I grab the hardware configuration, I could use that again as well.

Are these valid assumptions?

Just a couple of remarks on my setup. I am not super deep into the nix language yet, but I am using NixOS as my main operating system.

  1. Get into flakes as quickly as possible if you really want reproducible builds and keep everything controlled with git. I sure hope they will loose their “experimental” status in the not-so-distant future. For now you have to enable the flake commands in nix the package manager to use them.

  2. Home manager is written almost entirely in nix. And it fits nicely into my flake based config. I personally like it because I keep userspace from system a bit more separated this way.

  3. For “package building” take a look at how to create derivations. I can’t say I would be of great help there though :slight_smile: Mostly what I end up doing is modifying existing derivations to fit my needs.

2 Likes

It all helps. It gives me context in a more expedited way. :+1:

As of 22.05 there’s now a graphical guided installer, so the install process should be pretty easy now (I haven’t actually used it, myself, however). As far as I know, the configuration.nix generated by the graphical installer doesn’t differ much between the different ISOs. To the extent it does, you can change it by altering a line or 2. You’re not so much picking which desktop environment the final system will have as just which desktop environment the installer will have.

One thing worth considering about NixOS is that the main reason you normally don’t want to stray too far from the defaults is largely gone on NixOS. In a typical system, you lose track of all the various changes you’ve made and how they fit together, or they’re not properly respected by updates, etc. On NixOS, these problems go away because all those things are stored in your configuration. They’re not “brittle” anymore. It’s one of the joys of NixOS. :slight_smile:

The nixos manual has directions for how to install (until recently this was the normal way to install “from the iso”, which I presume you mean something a bit different by).

home-manager is like nixos, but for your home directory (aka dotfiles) rather than your system configuration. I definitely recommend using it at some point, but probably not immediately. Get used to the concept of declarative configuration first using NixOS, then when you’re ready to stretch further, you can dive into home-manager.

Not immediately, no. Flakes are still considered experimental, though they’re widely used already by the experienced members of the community. They’re dependable, and ultimately a significant improvement, or people wouldn’t be using them so much, but there are still a lot of things that don’t integrate smoothly with them yet. For a new user just trying to figure out what everything means, those extra hiccups could prove the difference between loving it and giving up.

NixOS uses Nixpkgs as its package repository. It’s one of the most complete and up to date package repositories in the open source community, if the stats are to be believed. In practice, I’ve found it’s quite rare that I want to use software and it isn’t packaged already.

That said, you can write your own nix code to make a package, and you can even put that nix code directly in your configuration.nix. How hard it is to do so often depends a great deal on what language ecosystem and build system are used for the software in question. For autotools projects in C/C++, for example, you seldom need to do much more than tell it where to get the source code and what the dependencies are.

Install, either by following the nixos manual (it’s truly not that hard) or by the guided installer, then start the loop of deciding you want something different, finding out how to edit configuration.nix to get that, then editing it and running nixos-rebuild switch.

I would recommend you make your configuration a git repository as soon as possible, and commit often. At least if you’ve used git before. You’ll do stupid things with your config, especially early on, and it’s nice to be able to refer back to what it was before you messed with it.

It’s also a decent idea to join the Nix/NixOS discord server (check Nix Community | Nix & NixOS, under “other platforms”). It’s a fairly laid back environment and about the right level of activity to get good answers fairly quickly. It is unofficial, however.

Good luck :smiley:

4 Likes

Also, a few newbie traps to be aware of:

  • You’ll see stuff all over the place suggesting you use nix-env -iA… don’t. See Stop using nix-env and Depreciate the use of nix-env to install packages?.
  • If you try to run a binary compiled for normal linux distros on nixos, you’ll probably get a very confusing No such file or directory error from bash, despite the file clearly being right there. What doesn’t exist is the ELF interpreter (ld-linux.so) specified in the binary (or possibly the interpreter specified in the hashbang). The solution is generally to write a derivation that autoPatchelfs the binary to use a version from the nix store, as well as find its libraries there, since there’s no global library search path on nixos. Another quick & temporary solution is to use steam-run.
  • nix-channel can be used as a normal user or as root, but it will manipulate a different set of channels in those 2 cases. Make sure you call it as the user you mean to (for a NixOS setup, that’s usually root).
  • When you go to install something, first check for a configuration module, and if that doesn’t exist, then install in environment.systemPackages. This is because environment.systemPackages literally just puts stuff in PATH (and a few other search paths), and can’t do any more complex configuration and integration stuff, which might be needed, depending on the software.
  • nixos-rebuild switch --upgrade ONLY updates your nixos channel. If you use another channel like home-manager, you’re better off updating with nix-channel --update.
  • Don’t install libraries globally. It doesn’t do anything. If you need them for development purposes, that’s where dev shells come in.
9 Likes

One meta-tip: all of the foregoing is great advice, but (if your experience is going to be anything like mine) much of it won’t make any sense to you until you’ve been steeped in the Nix way for a bit. More than anything else I’ve learned about recently, a lot of Nix/NixOS advice looks like hieroglyphics until you learn and try a few things on your own–then, revisiting advice like that in this thread suddenly becomes a lot clearer. So in the meantime, don’t lose heart, try things on your own system, and ask liberally for help here and elsewhere.

Godspeed!

3 Likes

I really want to stress these - If you run into issues after using the distro for a bit, going down that checklist will help you fix almost all problems.

And you’ll avoid a good 60% of them just by heeding the first point. Understanding why can come later :wink:

For the second point, Packaging/Binaries - NixOS Wiki is helpful, once you need it. Note that lots of - especially dev - tooling will have random external binaries that you’re not explicitly aware they’re downloading. npm projects like downloading custom built binaries, for example.

1 Like