I’ve been hearing a lot about it lately and I’m intrigued, but also utterly confused.

Is this a Linux distro I’d install on bare metal because it offers a new way of package management that addresses the issues other distros have?
Is it something I install in the distro I currently use?
How does it work and what does it do?

I’ve tried to read https://nixos.org/guides/how-nix-works but the first sentence is

“Nix is a purely functional package manager. This means that it treats packages like values in purely functional programming languages such as Haskell”

and that’s where it lost me. Thanks for helping me understand!

  • uniqueid198x@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    14
    ·
    1 year ago

    Ok, heres my run down:

    Nix is a package manager with the goal of making it so that when you install a package at a version, you always get the same thing.

    But isn’t that how all package managers work? Not at all. Most software requires other software to work (dependancies). Those dependencies also have dependencies, and so on. If a version of the dependency changes between installs, your package works differently. So Nix forces the package to specify what version of the dependency to use.

    But version numbers are pretty wishy-washy, so nix actually requires git commits. This is good, since it turns out, the compiler and libraries used to build the software are dependencies, too. Building with a different compiler can change the way the package works. So Nix forces the package to specify how to build it also.

    So Nix is a package manager where each version of a package is built against a known compiler, and comes bundled with a known set of dependencies.

    This allows some cool things, like generations. Change your list of installed packages (or configuratian, it handles that too), nix can save the old config and instantly go back to it. No more bricked linux install (if it can get past the bootloader). Also lets you do os-level per-directory installs. Have two projects that each need a different version of c compiler or postgres? Nix makes that easy. Want to make sure all dev machines in your project have the same python version? Just check in the config.

    • KISSmyOS@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      First of all, thanks. But I’m dumb and need the basics…
      Is it part of a distro with its own repo, its own package versions, maintainers?
      Or can I install it on any distro?
      Or only supported ones?
      If so, how do Nix-installed packages integrate with those of the base distro?
      Is it something I can run on my main system and game with, or still at the concept stage?

      Or am I completely off course here?

      • uniqueid198x@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        8
        ·
        1 year ago

        Yeah! Its a package manager, with its own repos. It needs its own becauseof all those guarentees above. Its designed to be installed on any linux distro, and also has windows, mac, and docker versions.

        If you want it to be all nix all the time, thereis also a distro NixOS thats uses nix from front to back.

        And, in a confusing failure of naming, the language you use to configure nix is also called nix, just to be cool.

      • dai@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        Compatibility for games will be the same under Nix as they are Debian, Ubuntu or Arch. If your using steam just toggle compatibility and you’ll be set for most titles under that launcher. I’ve ditched windows in favour of Linux, jumped between Debian, Manjaro and settled with nix.

        Nix has been around for 20+ years now, it’s quite mature at this stage, but has lots of features under development.

        For me, nix is a reproducible environment, the same code for my install will build the same working system with the same configuration for applications even if a drive goes bad.

        My sensitive data is stored elsewhere, but my keybinds, themes and wallpapers, colour schemes for applications and even settings in those applications will be the same on a fresh install (so long as I’ve defined them 😅)

        Majority of my config is identical between different machines, lots of reused config with minimal machine specific config.

  • ck_
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    1 year ago

    The Nix / NixOS documentation is notoriously bad and that sentence is a prime example.

    My advice, you can probably get on quicker with YouTube than with the official documentation. Or you can just muddle through like I did. Might take you longer though.

    I’ll take a shot at unpacking the functional part though: Imagine a system like a math equation, like “solve for x”. The system is the result of that equation. You define a couple of constants, like “I want it to run KDE” and nix will try to fill in the variables, eg. to run KDE you need bash, python, Wayland, etc. Like in school, you can break this equation down further, eg. to solve for Wayland, you need wlroot, mesa, some libs, etc. In the end, nix will solve your equation to a system that has everything that you want. Not only packages, also systemd units, your whole /etc and so on.

    It’s of course much simpler to imagine it like this. NixOS essentially builds your system from the ground up using a configuration file instead of by running a bunch of commands. Each configuration change produces a new system in the same sense that 4 = x + 3 solves differently than 5 = x + 3. The essential part is that Nix always solves the equation forward, if you will. So where apt-get install foo-service would put a line into /etc/groups, changing the file in place, Nix would replace the whole file because it knows what the file has to look like at all times given the configuration. Further more, it keeps the old configurations around. So if you liked your system better solving for 4 than for 5, you can just go back. Since Nix knows exactly how the system needs to look for 4, there is no “mess” because it does not need to remove things. It always builds forward.

    Hope that makes some sense :D