• harsh3466@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    9 hours ago

    I just took a run at nixos the other day, and I hit a wall.

    I installed NixOS just fine, but when it came to looking for direction/documentation/tutorials to begin learning how to use and write my config, I just got more and more confused.

    If anyone can suggest a good tutorial series, be it video or written, to get up to speed on nix language and config, I’d be grateful.

    I’m a faily experienced Linux user, no expert, but comfortable at the command line, comfortable with bash scripting, comfortable managing my server. I can usually dive into something like nix and get a finger-hold on understanding, but I spent hours trying to find some clear tutorial and I just ended up more confused.

    • balsoft@lemmy.ml
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      1 hour ago

      This is a pretty good list of tutorials for Nix (as the package manager thingy) (not NixOS): https://nix.dev/tutorials/#tutorials

      Here’s a tutorial for the Nix language: https://nix.dev/tutorials/nix-language

      As for the configuration.nix file, TBH, once you understand the Nix language you can just go around and look at what other people have written to get the inspiration. There’s a list of NixOS configs here: https://wiki.nixos.org/wiki/Configuration_Collection. Some of them are quite complex (as is mine), but you can start with something simple, maybe like this: https://bitbucket.org/bzz/nixos/src/master/configuration.nix . It will give you an idea of how to set config options and how the imports system works. To then see which config options are out there, look at https://search.nixos.org/options , you can search for anything you like (e.g. services, programs, networking, random system configuration stuff). You should never ever edit anything in /etc other than configuration.nix manually, always look for config options to do it.

      There’s technically documentation about it here: https://nixos.org/manual/nixos/stable/#sec-configuration-file , which can be helpful, but it’s also kinda long for what it tries to explain.

      Once you get the basics, you can look into flakes to replace stateful channels, making your configuration more modular to reuse it across multiple machines (now it’d be time to look at those more complicated configs), using home-manager to also manage your $HOME (so that you don’t have to touch ~/.config manually either), and maybe even impermanence to make your system reset to whatever is in your NixOS config on every reboot, erasing any accidental edits to configs, to make sure that your configuration reflects what exactly you want from your machines.

    • Laser@feddit.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 hour ago

      The issue I see with your approach is that you’re looking for a tutorial for something that is basically infinitely flexible, there’s multiple ways to do things, etc.

      By installing NixOS, you have already completed the tutorial. My advice is: Approach your configuration (which is actually code) like a static one first. That is set the values you want, maybe split up files a bit, keep it simple. At one point, you’ll get somewhere where you think that there has to be a better way to do it than just write down everything explicitly. Then, approach problem per problem. At least that’s how I did it.

      Dunno if that’s the best way to do it, if you want to start managing a server farm right now that approach won’t scale of course. The issue with configurations you find online is that they’re rather complex – which makes sense for the cases these people have written them for. But for one or two machines, you don’t need to fold attributes / generate attributes from list etc. right away. If you’re not in a rush, get a feel for everything on a low level first, and then approach the deeper mechanics.

  • jevans ⁂@lemmy.ml
    link
    fedilink
    English
    arrow-up
    7
    ·
    17 hours ago

    This is so funny. I explained Nix to my partner last night in nearly the same way.