Pinning Nixpkgs without Channels

submited by
Style Pass
2024-10-20 12:30:06

Nix Channels is probably one of the most controversial parts of the Nix. While Nix claims to be fully reproducible, Nix derivations implicitly refer to a nixpkgs usually through a channel. This breaks the reproducibility promise because the version of nixpkgs depends on the environment that the derivation is built.

One popular alternative for the traditional Nix derivations is to use flakes. There are even efforts to stabilize them for a long time. However, they are a whole new approach and require some learning for a traditional Nix user. Moreover, they are still experimental so the API is subject to change in the future.

In this post I will show how you can get rid of channels but still use the traditional nix derivations and pin your nixpkgs for your derivations, shells, NixOS configuration and home manager configurations. In the end you will end up with a setting where nixpkgs version is managed via plain text and can easily be updated when desired.

You may wonder, what does <nixpkgs> mean in this code?. This syntax is called "lookup path"[1]. When you write a name in angle brackets, it's matched with the corresponding key-value pair in NIX_PATH environment variable. The value is typically a Nix channel.

Leave a Comment