wiki/structured/tools.nix.org
Gabriel Arazas edc686c25c Update wiki on various topics
This update is too large, I made too many notes on stuff. Nonetheless,
it is very nice to see progress. I've made note revisions on the
following topics:

- Learning
- Writing
- Various Linux-related stuff

I've yet to start learning illustration but I'll be starting tomorrow
for an update how do I keep in mind with those writings. There are still
a lot of things to be processed from the backlog with yet more notes on
learning but I keep having those perspectives whenever I practice so
ehhh... Better have those than nothing?

Furthermore, I've also updated the timestamp format. It is pretty simple
to update all of the notes with a couple of `sed` calls.

Aaaand, I've also changed the way how the assets stored with the folders
only leaving it up for the generated files instead of enforcing it on
every note. I create more visual aids and managing them is a pain for
each note. This restructuring frees me of that burden.
2021-07-20 19:52:43 +08:00

7.2 KiB

The basics of Nix package manager

Nix package manager is a great tool for reproducibility as you can easily set up your environment. Taking it up to the next level with NixOS, your whole installation.

Among other things, Nix also has the following features to look out for.

Ecosystem

The basic ropes into getting started with Nix.

  • nixpkgs is the official package set similar to Flathub for Flatpak. In terms of size, nixpkgs is comparable to AUR.
  • NUR is the user-contributed Nix packages curated by the community. While most of the packages can be passed into nixpkgs, most of them are niche packages (or the package author are not interested in maintaining it).
  • direnv has integration with Nix as well as a lot of editors.
  • lorri replaces nix-shell integrating with direnv.
  • niv provides a easier way to manage dependencies though it will be easier with Nix flakes.
  • /foodogsquared/wiki/src/commit/edc686c25ced45a7bc66898cfacd9e369fdf1394/structured/Nix%20flakes is an upcoming feature for Nix, replacing the traditional Nix channels into a decentralized set of derivations that can be retrieved from anywhere similar to Go modules 1.
  • Cachix is a cache service enabling to easily distribute binaries built with Nix.
  • DevOS is a configuration framework for deploying NixOS-based systems.

Components of the package manager

Holistically, Nix is made up of at least four components: the store, the language, the derivations, and the sandbox.

  • The store is a immutable centralized location where all of the outputs are placed.
  • The derivations are essentially build instructions.
  • The language (also called as Nix but we'll refer to it as Nixlang) is a domain-specific language for creating derivations.
  • The build process can be locked in a sandbox, improving the reproducibility of a setup and lowering the attack surface for a malicious package.

Overlays

You can override values in Nix as a way to customize nixpkgs. For example, if you want to use a different version from the nixpkgs channel, you can change the appropriate value.

let overlay = self: super:
      {
        ncmpcpp = super.ncmpcpp.override { visualizerSupport = true; };
      }

For another example, you can see some examples from Neovim and Veloren (which also uses Nix flakes).

You can set overlays automatically either by setting nixpkgs.overlays from your system configuration or ~/.config/nixpkgs/overlays/ folder for user-specific settings. You could also set overlays for standalone Nix code similarly through the overlays key — e.g., import <nixpkgs> ? { overlays = (self: super: { } ); };.

Opinionated guide to learn Nix

Nix throws a bunch of traditional concepts behind as well as pioneers a bunch of things creating a steeper learning curve. The official documentation for Nix is pretty great at covering ground of all Nix stuff which makes it good as a reference but horrible for a newbie who wants to gain a quick overview of what Nix is all about. So I'll list a bunch of resources that helped me becoming comfortable with the Nix thing.


1

At a glance, anyways. I'm not experienced enough with Go to say that with utmost confidence.