Nix

Updated: 15 November 2025

Notes

Taken from here

  • Search for the packages which provide a program https://search.nixos.org/packages
  • A package name is not the same as a program name. Many packages provide multiple programs, or no programs at all if they are libraries. Even for packages that provide exactly one program, the package and program name are not necessarily the same.
  • Free up some disk space occupied by the different versions of programs downloaded nix-collect-garbage.

Flakes

  • Flakes are experimental but recommended.
  • A flake reference is a string representation of where the flake is located.
  • A Nix flake is a directory with a flake.nix and flake.lock at the root.
  • Flakes take Nix expressions as input.
  • Flakes can use the outputs of other flakes as inputs.
  • Flake outputs are defined by a function.
  • Flakes can have multiple simultaneous outputs.
  • The output of a flake is a Nix expression.

A flake output can be used to:

  • Build Nix packages.
  • Run programs.
  • Create development environments.
  • Launch NixOS systems.

See here for more details.

Home manager

https://github.com/nix-community/home-manager

Nix Shell

Run a program without entering a nix shell

nix-shell -p cowsay --run "cowsay Nix"

Enter a nix shell making 2 new packages available

nix-shell --packages cowsay lolcat

Enter a nix shell including Java Development Kit version 17

nix-shell -p jdk17

Enter a nix shell which includes PHP 8.4

nix --extra-experimental-features "nix-command flakes" shell nixpkgs#php84

Leave a comment