Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions source/guides/recipes/dependency-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,34 @@ All the imported entries will be updated, so they won't necessarily point to the

## Managing NixOS configurations

NixOS relies on the `NIX_PATH` environment variable to locate `nixpkgs`, which defaults to using channels.
To instead use a `nixpkgs` version managed by `npins`, one can manually override this environment variable on system rebuilds:
NixOS defaults to using channels to locate `nixpkgs`.
You can instead pin a version using `npins` from the `system.nix` entrypoint (available since 26.05):

```nix
let
sources = import ./npins;
in
import "${sources.nixpkgs}/nixos" {
configuration = ./configuration.nix;
}
```

Before NixOS 26.05's `system.nix` use:

```bash
sudo NIX_PATH="nixos-config=configuration.nix:nixpkgs=$(nix-instantiate --raw --eval npins -A nixpkgs.outPath)" nixos-rebuild switch
```

If you use npins with `system.nix`, disable channels in your configuration:

```nix
# configuration.nix
{
# ...
nix.channel.enable = false;
}
```

To make such pinned dependencies available as [look-up paths](https://nix.dev/tutorials/nix-language.html#lookup-paths) (like `<nixpkgs>`) while using the NixOS configuration, one may use:

```nix
Expand All @@ -126,7 +147,6 @@ let
in
{
# ...
nix.channel.enable = false;
nix.nixPath = lib.mapAttrsToList (k: v: "${k}=${v}") sources;
}
```
Expand Down
Loading