Nix derivations are instructions (recipes) for building a Nix package.
Nix derivations are instructions (recipes) for building a Nix package.
writeShellApplication
The recommended way to create Derivation using shell scripts.
text attribute.We used callCabal2nix function from nixpkgs to build the todo-app package above. This functio generates a Haskell package Derivation from its source, utilizing the “cabal2nix” program to convert a cabal file into a Nix derivation.
While package management is the key purpose of Nix, its derivations can also be used to produce non-package types, such as development environments (aka. “devShell”).
The directory used by Nix to store store paths (including derivations).
This is a simple flake that exposes a package (a writeShellApplication Derivation wrapping lsd), that can be `nix run`ed to list the contents of the root directory.
Normally we can achieve this by refactoring our Nix expression to be a function (see lsdFor ⤵️) that takes arguments for these variations (dir and tree ⤵️), producing the appropriate derivation as a result:
Nix expressions are evaluated to produce derivations (among other values). These derivations when realized usually produce the compiled binary packages. Sometimes, realizing a derivation can produce a Nix expression representing another derivation. This generated Nix expression too needs to be evaluated to its derivation before it can be realized. This secondary evaluation is achieved by importing from the derivation being evaluated, and is called “import from derivation” or IFD.
[!info] nix run nix run command will run the specified package from the flake. Here nixpkgs is the flake, followed by the letter #, which is followed by the package (Derivation) name cowsay that is outputted by that flake. See Flake URL for details on the syntax.
Technically, a Nix package is a special directory (a Store path) inside the Nix Store (/nix/store), built using instructions from a Derivation.
A binary cache provides cached binaries of built Nix Derivation.