5

When querying for hackage packages, the manual suggests using the command:

$ nix-env -f "<nixpkgs>" -qaP -A haskellPackages

Thus we define the 'active Nix expression' to be "<nixpkgs>" when searching for Haskell packages.

What does this expression "<nixpkgs>" mean and where is it defined? I do not have a channel by that name, nor do I see it occurring in my /etc/nixos/configuration.nix file.

chepner
  • 497,756
  • 71
  • 530
  • 681
mherzl
  • 5,624
  • 6
  • 34
  • 75
  • 1
    This is a duplicate of https://stackoverflow.com/questions/47379654/what-does-the-nixpkgs-string-value-mean-in-nix/47388602#47388602 – Robert Hensing Jul 13 '19 at 10:55

1 Answers1

6

From man nix-env (and likely other sources):

   NIX_PATH
       A colon-separated list of directories used to look up Nix
       expressions enclosed in angle brackets (i.e., <path>). For
       instance, the value

           /home/eelco/Dev:/etc/nixos

       will cause Nix to look for paths relative to /home/eelco/Dev and
       /etc/nixos, in that order. It is also possible to match paths
       against a prefix. For example, the value

           nixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos

       will cause Nix to search for <nixpkgs/path> in
       /home/eelco/Dev/nixpkgs-branch/path and /etc/nixos/nixpkgs/path.

On my machine, NIX_PATH is nixpkgs=/Users/me/.nix-defexpr/channels/nixpkgs, so <nixpkgs> refers to the nixpkgs channel that I am subscribed to.

In general, <...> causes a path to be treated not literally, but as found in some directory specified by your NIX_PATH.

chepner
  • 497,756
  • 71
  • 530
  • 681