3 ms·
> Why should I invest time? It's not for everyone. Specifically, because Nix's 'costs' are upfront (for likely future benefit), nix isn't well suited to just-
by rgoulter 4y ago
> Why should I invest time?
It's not for everyone.
Specifically, because Nix's 'costs' are upfront (for likely future benefit), nix isn't well suited to just-get-it-done pragmatic attitudes. -- e.g. if you'd prefer to just launch VMs from the web console, over using a tool like Terraform, then Nix isn't going to be for you.
Nix isn't too difficult to use. I'd say it's 95% wonderful, 5% huge pain to deal with. (Writing new nix code can be very hard).
As to why it's worth learning:
> What makes it stand out?
Nix provides very expressive control over packages of software.
e.g. With nix, it's easy to have multiple versions of the same software running on the same system. Whereas, with package managers, if you upgrade, you aren't able to easily also keep the old version around.
Some of the use cases Nix allows are pretty neat:
- You can declare a set of development tools to be made available. So, when you load up the project, you don't have to copy-paste "apt-get install...". This is especially useful for side projects you might not touch all the time.
- There's a "nix run" command, which can act a bit like "docker, without containers": it will download the package, and run it on the host.
- NixOS makes use of Nix so that the system configuration is all declared starting from a single file. Rolling back changes to system configuration is easy, in case you accidentally misconfigure the system. -- This can be used to build container images or VM images.
- Nix can be used to declare what packages you want installed for your user, and declare the configurations for these files. This allows ensuring you have a familiar setup quickly on a new computer.
All sorts of programming involves dealing with packages.
To clarify a bit on the details: nix declares packages in a pure way, using all of its inputs (source code, compiler, library dependencies; which are themselves declared with nix), and builds these in an isolated/non-global directories. Packages are 'installed' by symlinking to where the package is placed.
- fuball63 4y agoHow does Nix compare to Environment Modules: https://modules.sourceforge.net/ https://modules.sourceforge.net/ Am I correct in understanding they are similar, except Nix has the "pure" package building?
- rgoulter 4y agoI'm not familiar with Environment Modules. I see they're popular in HPC? One difference: On Nix's homepage (https://nixos.org https://nixos.org), the first word which stands out is "reproducible". -- If I search the read the docs for "reproducible", the word shows up once. https://modules.readthedocs.io/en/latest/index.html https://modules.readthedocs.io/en/latest/index.html Not sure if there's anything recent, but links from this may be useful: https://github.com/freuk/awesome-nix-hpc https://github.com/freuk/awesome-nix-hpc
- rekado 4y agoThis is not Nix, but in showing the Environment Modules support for Guix the blog post also shows how functional package management (as implemented in Nix and Guix) differ: https://hpc.guix.info/blog/2022/05/back-to-the-future-modules-for-guix-packages/ https://hpc.guix.info/blog/2022/05/back-to-the-future-module...
- pxc 4y agoHelpful article and cool feature! Thanks for sharing
- forgotpwd16 4y agoModules imperatively modify the current (shell) environment (PATH and other variables) but you've to install anything required by modulefiles yourself. Nix handles package management and also allows you to declaratively create an environment to which you enter. For example `module load gcc` will bring gcc to your environment but it must already be installed by the administrator. On the other hand on Nix, you can either do something similar with `nix-shell -p gcc` which will give you an environment with gcc that if it isn't available on store will download it, but you can also create a `shell.nix` where you specify anything you need explicitly (have those packages available, download those dependencies not available as packages, make those config files, etc). Overall Modules has only a part of the functionality offered by Nix. *Although `nix-shell` in newer unified `nix` command has been broken to few subcommands. Can find more info at https://blog.ysndr.de/posts/guides/2021-12-01-nix-shells/ https://blog.ysndr.de/posts/guides/2021-12-01-nix-shells/ if interested.
- Izkata 4y ago> nix isn't well suited to just-get-it-done pragmatic attitudes Depends on what exactly you're trying to do. I discovered nix years ago when I was trying to install a newer version of Java than was available in the Ubuntu repos, and the "nix-env" method (just using nix as a package manager without the declarative config) was the only thing that just worked with no hassle.
- pxc 4y agoMy first encounter with Nix was using it that way to get my favorite tools on the university computer lab without convincing the admins to install them for me. Today, some Steam Deck users are using Nix to supplement their console's desktop experience with familiar tools without the overhead of Flatpak or the risk of modifying the base system (in which case modifications are nuked on SteamOS updates anyhow). Determinate Systems did some work to enable and document that, and one YouTuber recently posted an intro/walkthrough of their docs as well. Video: https://m.youtube.com/watch?v=ttOs5iWgNzk https://m.youtube.com/watch?v=ttOs5iWgNzk Secondary documentation (YouTuber's blog): https://christitus.com/steamdeck-as-a-desktop/ https://christitus.com/steamdeck-as-a-desktop/ Primary documentation by Determinate Systems: https://determinate.systems/posts/nix-on-the-steam-deck https://determinate.systems/posts/nix-on-the-steam-deck (Some of the work relevant here was done by folks outside of Determinate Systems as well. The installer workgroup is not exclusively DSers.) Sometimes it just fits a use case so much better than alternatives that it's an obvious choice.