# Nix package manager

Date: 2021-06-05 12:34:49 +08:00Date modified: 2021-07-28 16:31:56 +08:00

Nix is a package manager that pioneered Functional package management which addresses the criticisms of traditional Unix systems while making it as a specialized tool for Reproducible builds. It features a handrolled configuration language (also called Nix) that leans into functional paradigm, making it easier if you have experience on it. A popular tool mostly featured in Haskell programming projects.

Eventually inspired GNU to create a fork, Guix package manager, that takes it to another direction with more focus on reproducibility and its extensions such as bootstrapping.

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

- Creating Reproducible executables with Nix enabling to execute with one script only requiring the package manager.

- How the build process works along with Nix derivations.

- With Nix overrides and overlays, you can change parts of a system and/or packages.

- The new way to manage channels with Nix flakes.

- How Nix packages are built and eventually created an extensive package ecosystem with the Nix language.

# 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.

- Nix flakes 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 .

- 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.

- Nix language 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.

## Backlinks

- Guix package manager
- Common problems with software packaging
- Functional package management
- Openness makes diversity
- GitHub Actions
- Software Heritage
- Software archives
- Nix language
- NixOS
- The Packaging Grail
- Nix packages