# Nix packages

Date: 2021-07-18 21:23:26 +08:00Date modified: 2021-12-12 23:48:08 +08:00

- the most important component managed with Nix package manager are Nix derivations

- derivations are basically recipes how the Nix build daemon compiles the package

- most derivations are verbose but we can easily create one with nixpkgs

- for certain setups such as common conventions for certain programming languages like Rust and Go, nixpkgs has environments created for those; different versions may have changes so be sure to go into the appropriate documentation and create packages for a specific channel; this is significantly easier with Nix flakes

# Ecosystems

- while derivations can be interacted with the builtin function `builtins.derivation`, it isn't really recommended since it is very verbose; instead, you use `stdenv.mkDerivation` from nixpkgs

- nixpkgs is the official repository of NixOS containing the standard library extending the Nix language, the largest repository of packages (counting up to 80,000 as of 2021-12-12), and various NixOS modules used to build the system itself

- nixpkgs contains `stdenv` which is a derivation meant to be a base for other packages

  - stdenv contains base packages that virtually all packages have (inside nixpkgs)

- `stdenv.mkDerivation` is a convenient way of creating derivations; however, it is very abstract and a lot of events happening around it

  - this is a function that accepts a large attribute set

  - it will map its arguments corresponding to a parameter in the final derivation made with `stdenv` (which is a shell script)

  - attributes are usually just variables; this is especially prevelant if

  - packages can also set setup hooks (i.e., `setupHook`) that are essentially shell scripts to be added in the final derivation

    - example: cmake, glib, and most of the build systems at nixpkgs

## Backlinks

- Flatpak packages
- Nix package manager