How to start using Nix(OS)

Hello everyone
I’m currently using void linux, but there are no packages for some programs. And sometimes it would be easier if systemd was also supported… Now I’ve tested NixOS in a VM and have everything running in classic mode. This is great in conjunction with the packages via NixOS Search. Now I wanted to roll it out on my computers, but then I read that everything is in the process of being converted to flakes…

To be honest. What is most important to me is an extensive package store, like the AUR. Fewer functions that you can go back to old versions. So far I have copied the files from .config/ etc. when migrating to new computers, which is also ok.

Anyway, what’s the best way? Waiting for a release with integrated, unified flakes support, or what is the best method? I’ve read a lot of documentaries, watched a lot of VT videos, and the “solutions” are different everywhere. That doesn’t make it any easier.

Who can advise me?

Thank you.

1 Like

My two cents:

Don’t worry about flakes. The home user giving NixOS a try doesn’t need them, and they’ve been experimental for years with no hint that stabilization won’t take longer. People in Nix shops, who have an interest in making sure that the entire dev team runs everything on exactly the same software that gets deployed and not something that depends on something that is one minor version off, have the sorts of problems flakes are best at solving. You probably don’t.

Follow the NixOS Manual’s installation guide, and then the Home Manager installation guide for NixOS if you don’t want to use sudo to configure your user’s programs from /etc/nixos/configuration.nix. Don’t use nix-env to install anything; use nix-shell -p to try programs in a temporary way, and then use home-manager edit (or sudoedit /etc/nixos/configuration.nix if you didn’t go with Home Manager) to add them to your profile in a less temporary way. That’s the least confusing way to get started.

4 Likes

So far I have done this by entering everything in /etc/nixos/configuration.nix. But it would be stupid if in a few months this route no longer works by default in a new ISO.

That won’t happen for the foreseeable future. We’re likely years from flakes being enabled by default; Nix might not ever see the day when non-flakes configurations are no longer supported.

1 Like

Of course, it is important that the selection of packages does not become less and less. Even with proprietary software such as Teamviewer, Whatsapp for Linux or MS Teams… what is sometimes needed…

Mate, you’re overthinking this! The availability of packages in Nixpkgs doesn’t change whether you’re getting them from a flake or not.

I suppose the one sense in which it matters is that a project might define a flake.nix file in its own repository, and it’ll be easier to understand installing that package from a configuration that is already using flakes. But of course proprietary software isn’t doing this.

Nixpkgs can be used with or without flakes, and Nixpkgs is the default collection of packages that has the hundreds of thousands of entries that you’ve probably seen boasted about here and there.

2 Likes

OK, I understood that flakes and home managers should be seen as one unit. I currently don’t have a home manager installed in the VM. Then I just want to let it happen. I have already successfully restored my program settings in the VM. Then nothing can go wrong…

Many thanks

BTW. Just one thing. For example the package “rustdesk” is at version 1.2.2. But the latest stable release is 1.2.3. Should i simply wait for it, or can i support the nix project by creating a newer package, if i know how to do this of course…??

You can open a PR to bump the package version. If you’re lucky, you’ll just be changing the version and the hash. (If you’re less lucky, changes to the package may require adjusting the expression that builds it.)

If you do, it’s a good idea to search all pull requests on GitHub - NixOS/nixpkgs: Nix Packages collection & NixOS to make sure someone hasn’t already opened a PR for it. (This is especially true if you’re using a stable channel of nixpkgs, such as 23.11–the package may have already been updated in master.)

That said, there is a bot that automatically opens bump PRs for many packages as long as it can tell there’s a newer release, and bumping the version+hash is enough to get it building. If the release is very new (maybe the past week or so), it’s pragmatic to wait and see if the bot handles it. You can also proactively check the bot’s logs (Index of /log/) to see if the bot has tried and failed to update it.

Please provide sources for where you read that.

Here’s a (still incomplete and still unfinished) account on the state of affairs compiled by the documentation team:

A recent blog post by @jade, despite a funny title, represents the situation quite close to reality: Flakes aren't real and cannot hurt you: a guide to using Nix flakes the non-flake way - jade's www site (I’d like to have more of that on nix.dev!)

Note that there is nothing special about /etc/nixos/configuration.nix except nixos-rebuild using that location by default. You can put your NixOS configuration anywhere you like and point nixos-rebuild to that file. The module system in NixOS is not going anywhere. All you have to watch out for is pinning your sources so the package set you’re working off does not drift away inadvertently. There are multiple options for pinning, including the tools mentioned in the the @jade’s blog post, but the principle is the same everywhere: specifying commits explicitly.

2 Likes

I agree with others: flake is nothing special, you can start without, and if at some points you need it it’s just adding 5 lines in a new file. I like to see flake as mostly a convention to organize packages in a channels to be easily discoverable + add a simple way to pin dependencies, so your non-flake knowledge will still help with flake.

What I would recommend however if you go to NixOs is to enable nix-ld so that you do not need to worry when running binaries not made for nix (e.g. if you use npm, it can save you some trouble if you just want to follow tutorials).

If you want to add new packages in Nix, you might also like my tutorials here (sorry for this shamefull advertisement):

2 Likes

Honestly i havn’t documented that and i’ve searched von nixos & flakes. So maybe thats the reason for that.

Would it be the best idea to change after running the iso setup to the unstable channel? The rustdesk package seems to be on unstable in the same version, if i’m right in looking on the search.nixos.org site unstable tab…

Thanks, i will read about that the next days.

Don’t worry… :wink: It needs more of that. And it would be best if everything is in a central location. A lot of information is often no longer up to date, or the user cannot judge whether this is the case.

As a new NixOS user as well (6 months) I use flakes and recommend them from my limited experience.

Here is the best guide that I have found:

1 Like

That i’ve already bookmarkt, but I was confused because after the section “Enabling Flakes Support” you are supposed to clear the configuration.nix, if I interpreted that correctly.

In the Enabling Flakes Support section, you add a line to your nix configuration to enable the experimental feature.

Then, you create a new file called flake.nix. This is in addition to your existing configuration.nix file.

Basically, the flake.nix is like the index.html or makefile of your nix configuration. It lists the inputs and outputs, both online and on your local machine.

So essentially, you create flake.nix with very similar parameters, and then tell it to look in configuration.nix for your system configuration. So it is in addition to configuration.nix, not overwriting it.

1 Like

True. I plan to add it to nix.dev (which is a really nice website for official nix-related tutorials btw), I just need to find some time to add it.

This post is a license grant to take whatever you would like from that blog post, verbatim, to put it on nix.dev under the appropriate license

1 Like

OK, have setup my first baremetal system. And this is my running config, with added unstable channel. As u can see, there are all packages in. Should i better let only git stay and put the rest packages in another position if using flakes… (on the baremetal the configuration.nix is untouched)

https://paste.simplylinux.ch/view/d7279cbb

To be honest, I don’t know what to do next? I activated flakes with the one line and looked at a few templates for flakes.nix. The idea was that I activate flakes and then continue to test things on the side. But first the basic system has to run with the packages stored in my config so that I can work with the system.

Is there a flake.nix in which I can enter the packages. Preferably in the unstable version.

I like the rolling release idea and like having up-to-date programs, even if something breaks in one package or another.

As I said, I’m not a programmer, but I would like to use the wide range of current packages.

Thanks for specific tips…

I am unable to see your flake currently, so unsure how to give you specific line-by-line advice. But I do hear you just wanting to get started, and it seems you have a preference for flakes.

Given this, I might suggest trying the same way I got started with NixOS: I looked at Misterio77’s starter templates (the minimal one was a good start for me) and went from there. I would advise reading everything as the comments and READMEs are important. Not saying I understood it all right away, just acknowledging how important it is to take the time to absorb the information.

Over time, I learn more about Nix and keep diverging significantly from those templates. But they were a good “scaffold” for getting started.

Nix is a programming language, so you will need to grow more and more comfortable with programming to sustainably manage a dynamic system or systems. That said, you can do this, just take your time, have some patience with yourself, and enjoy the struggle of learning a new thing!

Also underscoring what @mars-monkey noted: the “NixOS & Flakes Book” is excellent. Working through it myself.

1 Like