Starter or Usage Question

Hello,

I love the concept of nixos and I really want to use it.. I have some questions though

  1. When I get a error is sudo nixos-rebuild switch --show-trace -vv the best way to find the exact error?
  2. When i copy a snippet of a config to make something work that I need, how do I make sure it works. What do I look out for ?
  3. Can I use nixos without learning the language ? Can I just build up my config using snippets of other peoples ?

IF I can get this down I think I would love using nixos as a daily driver on all my laptops.. I first want to understand it then I should be good

Thanks

1 Like
  1. When I get a error is sudo nixos-rebuild switch --show-trace -vv the best way to find the exact error?

No, it’s pretty terrible: they way Nix evaluates your configuration up to an error can be very unintuitive and --show-trace tends to produce huge and mostly useless outputs.

I don’t know of a better way, but that’s generally a problem for syntax or type errors: this is something I make when writing complex code, not configuring NixOS. If you assign some invalid value to an option, or use a removed/deprecated option you get a nice error/warning message.

  1. When i copy a snippet of a config to make something work that I need, how do I make sure it works. What do I look out for ?

Just paste it into you configuration and do nixos-rebuild test to check. NixOS modules generally do some sanity check, so things can’t go too wrong, and you can also just roll back.

If you’re worried you can use nixos-rebuild build-vm to test your configuration in a clean virtual machine.

  1. Can I use nixos without learning the language ? Can I just build up my config using snippets of other peoples ?

Yes, just make sure to understand the basic syntax of Nix, as with any configuration language. You don’t need to do any programming to just build your system.

Check out the manual for how to install NixOS and configure the basic setup. Also check out the wiki for more.

When I get a error is sudo nixos-rebuild switch --show-trace -vv the best way to find the exact error?

I don’t usually use -vv but yes --show-trace is often necessary, it’s also helpful for finding out whether the thing that has been building for an hour is actually making progress.

When i copy a snippet of a config to make something work that I need, how do I make sure it works. What do I look out for ?

Make sure you understand the basic .nix language syntax, attr sets, function definitions, function calls. Look up the option on NixOS Search

  • Can I use nixos without learning the language ? Can I just build up my config using snippets of other peoples ?

Only on a very basic level. I don’t think using NixOS is all that beneficial if you aren’t planning to learn Nix.

Wow!

I think I want to get my system up And running first maintain it for a little aka install everything, make sure sound is working. Basically everything is working. Once satisfied learn the language.

That should be a good approach right ?

Thanks

1 Like

Thanks for the reply.

Wow thanks for the insight!

Wow the VM is a beautiful idea..

Thanks

Question.. Why I get errors when building the ^ is that the error I need to fix or is there a lot more to read from the errors ?

You see, there’s actually not much to learn about Nix the language, it’s a pretty simple and boring domain-specific language. You can fairly well characterize it as a JSON with functions (and comments, of course). The only novelty could be that it’s a purely functional and lazy language, if you’re not familiar with them.

What’s more complicated, and probably daunting at first, is the entire ecosystem that people have been building on top of it.

There’s Nixpkgs, which is a huge collection of packages, where each package is a Nix “program” that automates the compilation of some software. For example, there’s a package for Firefox, which is a Nix program that takes as inputs a bunch of tools and libraries and sources needed to compile Firefox and gives you the Firefox binary ready to be run.

Nixpkgs also contains lib, which is essentially the standard library of Nix. It includes utilities functions, types and the module system, the core of NixOS.

NixOS is basically a package that builds not just some software but an entire GNU/Linux distribution, in the way you define it to be by combining together modules, with each module configuring some portion of the system or some service or piece of hardware and exposing some knobs so you can tweak it the way you like.

So, what you’ll probably find useful in maintaining and organising your configuration is to understand (at a high level, mind you) is how the NixOS module system works. Say, the difference between options and config, which types options can be, what a submodule is, etc. And also what a package is, and how you can “override”, that is to say, customise it.

2 Likes

Thanks.

I got nixos on two laptops right now, got everything installed now its time to learn something.. I’ve always wanted it installed.

How do I find this information like what you said like the in’s and outs.. I installed nix-tree and that’s nice

I should probably google the package with nixos attached.. AInisnvrry good now days

Also the nixos package search is powerful

EDIT: Sheesh