doc/using/configuration: document NIXPKGS_CONFIG lookup order (#515272)

This commit is contained in:
Johannes Kirschbauer
2026-05-10 12:55:05 +00:00
committed by GitHub
+16
View File
@@ -31,6 +31,22 @@ Unfree software is not tested or built in Nixpkgs continuous integration, and th
Most unfree licenses prohibit either executing or distributing the software.
:::
The `NIXPKGS_CONFIG` environment variable can override the configuration file location.
Nixpkgs resolves the config in this order:
1. `$NIXPKGS_CONFIG`, if set and the file exists.
2. `~/.config/nixpkgs/config.nix`, if it exists.
3. `~/.nixpkgs/config.nix` (legacy), if it exists.
4. Empty configuration.
On NixOS, `NIXPKGS_CONFIG` points to `/etc/nix/nixpkgs-config.nix` system-wide.
Drop a file there to apply configuration to `nix-env`, `nix-shell`, and other user-level commands.
NixOS does not create this file.
The [`nixpkgs.config`](https://nixos.org/manual/nixos/stable/options#opt-nixpkgs.config) option does not affect `nix-env`, `nix-shell`, or other user-level commands.
This lookup applies to non-flake usage like channels and `<nixpkgs>`.
Flakes ignore it; pass `config` directly when importing `nixpkgs`.
## Installing broken packages {#sec-allow-broken}
There are several ways to try compiling a package which has been marked as broken.