doc/manual/source/command-ref/files/default-nix-expression.md
The source for the Nix expressions used by nix-env by default:
~/.nix-defexpr$XDG_STATE_HOME/nix/defexpr if use-xdg-base-directories is set to true.It is loaded as follows:
default.nix file, that default.nix file is loaded as a Nix expression.default.nix file, then its contents (both files and subdirectories) are loaded as Nix expressions.
The expressions are combined into a single attribute set, each expression under an attribute with the same name as the original file or subdirectory.
Subdirectories without a default.nix file are traversed recursively in search of more Nix expressions, but the names of these intermediate directories are not added to the attribute paths of the default Nix expression.Then, the resulting expression is interpreted like this:
Example
If the default expression contains two files,
foo.nixandbar.nix, then the default Nix expression will be equivalent tonix{ foo = import ~/.nix-defexpr/foo.nix; bar = import ~/.nix-defexpr/bar.nix; }
The file manifest.nix is always ignored.
The command nix-channel places a symlink to the current user's channels in this directory, the user channel link.
This makes all subscribed channels available as attributes in the default expression.
A symlink that ensures that nix-env can find the current user's channels:
~/.nix-defexpr/channels$XDG_STATE_HOME/nix/defexpr/channels if use-xdg-base-directories is set to true.This symlink points to:
$XDG_STATE_HOME/nix/profiles/channels for regular users$NIX_STATE_DIR/profiles/per-user/root/channels for rootIn a multi-user installation, you may also have ~/.nix-defexpr/channels_root, which links to the channels of the root user.