1. 49
    1. 9

      Nix changed how I deploy systems massively. I think the https://nixos.org website got updated recently to show what you can actually do with it, so the docs are requiring less of a “missing manual” at least.

    2. 5

      After using it for a while I started to find the Nix expression language as one of the best designed syntaxes ever. It doesn’t have separators for records or lists so it’s friendly to diff. The multiline strings are perfect. Writing nested records with “a.b.c” keys is super convenient. The lambda syntax is as simple as possible. Etc etc.

      1. 9

        It doesn’t have separators for records or lists so it’s friendly to diff.

        Records are separated with the ; symbol.

        As for lists, I beg to disagree. The list symbols are separated with a whitespace, which is unfortunate since whitespace is also used to represent function application. It means you’ll have to be careful enough to wrap your function applications in parenthesis every time you’ll perform it in a list.

        That’s a easy trap to fell into, especially in multi-lines statements. Add the lazy nature of the language on top of that, you can end up with stacktraces that are pretty difficult to decipher. Especially if you end up doing that in a NixOS machine description :/.

        I see a lot of newcomers falling into this trap on IRC.

        e.g:

        let pkgs = [
          htop
          import ./local-pkgs.nix
          ssh
        ]; in ...
        

        Instead of

        let pkgs = [
          htop
          (import ./local-pkgs.nix)
          ssh
        ]; in ...
        
        1. 2

          Sorry, I meant separators to mean comma-like separators where the last item doesn’t end with the separator.

          The issue you mentioned is real, yeah. I still love the syntax.

    3. 3

      I use Nix on my server, and I love it. Just like the post says, it’s almost mind blowing how easy it is to copy a configuration from one place to another. Once I got my blog building as a package, I just copied over the file, and NixOS took care of the dependencies, building, and HTTP(s) serving in very few lines of Nix code.

      The syntax is a little weird. As @NinjaTrappeur points out below (or above), the space separators in lists are easily confused for function application; I’ve had several instances of infinite loops arising from using a fixpoint combinator (or some other recursive thing) inside a list.

      My favorite thing about NixOS on the desktop, though, is that I don’t have to install stuff globally. For all of my homework assignments for class, I have a separate Nix expression that specifies the exact LaTeX packages that I need. But these packages don’t show up anywhere else, and if I get rid of my homework, or stop working on it, the dependencies will be gone from my machine after a GC.

      Speaking of GC. I think that “garbage” is a big problem with NixOS. I recently reclaimed 13GB of dependencies in a single “GC” command! If you’re not careful, all these packages can really pollute your system.

      1. 2

        Speaking of GC. I think that “garbage” is a big problem with NixOS. I recently reclaimed 13GB of dependencies in a single “GC” command! If you’re not careful, all these packages can really pollute your system.

        It also also depends a bit on which channel you are using. On my main development machine, I am tracking nixos-unstable-small. With somewhat regular mass-rebuilds on unstable, the store can grow pretty quickly. I don’t care so much, because I use a large NVMe SSD. But on my Mac with its 256GB SSD, I need to expire home-manager generations and collect garbage more aggressively.

        On servers and some other desktop machines I track the latest release and the store grows much more modestly.

        (Garbage collection can also run automatically at a given time with the nix.gc.automatic NixOS option.)

    4. 2

      Is there a concept of jails in Nix(OS)? Or is it somehow not as relevant?

      1. 3

        You can declare a list of docker containers to run: https://nixos.wiki/wiki/NixOS_Containers

        If you want the tight integrations, NixOS does have native support for running containers: https://nixos.org/nixos/manual/#ch-containers

    5. 1

      Even if you aren’t running full nixos, nix + home-manager is a revelation. Since quarantine started, I’ve had to use several different machines (a desktop at work, 2 different work laptops) and it makes getting up and running so much faster. Install nix, install home-manager, clone my dotfiles and run home-manager switch.

    6. 1

      The Nix language is syntactically very ugly

      tbh it seems as close as you can get to user-friendly while maintaning pure functional semantics, right?

      1. 1

        You make it sound like pure functional semantics are in conflict with user-friendlyness. But in my eyes the Nix language is user-friendly exactly because its semantics are purely functional. And you could change quite some things about the syntax without changing semantics to make it look more like other languages in this space: separate list items with a comma, define functions with a \ and ->, separate record properties with a comma, …

        1. 1

          At some point pure functional patterns are less user friendly than potential alternatives, but that’s not to say that I think the alternatives are better as they are often open to more potential issues.

          However, I do think that Nix is quite user friendly as far as pure functional configuration languages go, to be honest. That was my original point. Largely because it doesn’t look like other languages in this space - which are largely less user friendly imo.

          If commas were added to lists, I’d hope that they’d be functional - as I believe that the simplicity of lists/sets in Nix is one of it’s values and commas don’t add any value in my opinion here.