How to fetch Nixpkgs with an empty NIX PATH

From NixOS Wiki

You can fetch Nixpkgs with an empty NIX_PATH. This comes in handy if you want to remove impure references to the NIX_PATH from your code base.

To do so, you can use builtins.fetchTarball, like this:

  nixpkgs = builtins.fetchTarball {
    url    = "";
    sha256 = "0wgm7sk9fca38a50hrsqwz6q79z35gqgb9nw80xz7pfdr4jy9pf8";

  pkgs = import nixpkgs { config = {}; };


… replacing 3389f2… with the desired revision of Nixpkgs and replacing 0wgm7s… with the corresponding SHA256 hash.

You can use the following command to obtain the correct SHA256 hash to use if you prefer not to use trial and error:

$ nix-prefetch-url --unpack "${REVISION}.tar.gz"