# Nix ![[Nix language basics#^pm7mej]] ## Status and Info - For a list of nix releases see https://github.com/NixOS/nix/tags - For a list of current nixpkgs hashes see [Nix Channel Status](https://status.nixos.org) ## Documentation Links - Nix language itself - [Nix Reference Manual](https://nix.dev/manual/nix) - For a list of primitive operations written in C++, a.k.a. builtins, see [Built-in Functions](https://nix.dev/manual/nix/stable/language/builtins.html). - Nixpkgs - [Nixpkgs Reference Manual](https://nixos.org/manual/nixpkgs/stable) - Nixpkgs defines a large number of library functions written in nix as part of its lib attribute set. For a list see [Nixpkgs library functions](https://nixos.org/manual/nixpkgs/stable/#sec-functions-library). - NixOS - [NixOS Wiki](https://wiki.nixos.org/wiki/NixOS_Wiki) ## Profiles ![[Profiles (Nix Reference Manual)#^9yc1si]] ![[Profiles (Nix Reference Manual)#^5u7qwz]] Aside from the user profiles, nix has a channel profile as well, which determines which nixpkgs are used when adding packages to user profiles. Think of channels as nothing other than commit hashes pointing to the nixpkgs repo. ![[Nix Pills#^7nbue1]] For more info about profiles see [[Profiles (Nix Reference Manual)]]. To see the `nixpkgs` commit used by the current channel, run the following: ```shell cat /nix/var/nix/profiles/per-user/root/channels/nixpkgs/.git-revision ``` ## Installation Notes After a macOS update nix is not properly initialized, meaning it will not be available from the PATH. That is because its initialization script is called from `/etc/zshrc`, which is typically overwritten when a a macOS update is installed. To fix this either reinstall nix, return the following snippet to `/etc/zshrc`, or simply place it in `~/.zshrc`. ```sh # Nix if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' fi # End Nix ``` ## Scripting ```sh #! /usr/bin/env nix-shell #! nix-shell -i bash --pure #! nix-shell -p bash cacert curl jq python3Packages.xmljson #! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/2a601aafdc5605a5133a2ca506a34a3a73377247.tar.gz curl https://github.com/NixOS/nixpkgs/releases.atom | xml2json | jq . ``` `-i bash --pure` defines the interpreter for the rest of the file and specifies that no other packages should be used (`--pure`) `-p` specifies which packages should be available `-I` specifies the search path for packages