I am following this guide to set up nix and haskell-ng. But when I get to the step

nix-env -iA nixpkgs.haskellEnv

then I get the error:

error: attribute ‘nixpkgs’ in selection path ‘nixpkgs.haskellEnv’ not found

Any idea what is going wrong?

1

There are 1 answers

0
Peter Simons On

The command nix-env -f "<nixpkgs>" -iA haskellEnv should work.

Citing from http://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure:

Attribute paths are deterministic inside of Nixpkgs, but the path necessary to reach Nixpkgs varies from system to system. We dodged that problem by giving nix-env an explicit -f "<nixpkgs>" parameter, but if you call nix-env without that flag, then chances are the invocation fails:

$ nix-env -iA haskellPackages.cabal-install
error: attribute ‘haskellPackages’ in selection path
       ‘haskellPackages.cabal-install’ not found

On NixOS, for example, Nixpkgs does not exist in the top-level namespace by default. To figure out the proper attribute path, it's easiest to query for the path of a well-known Nixpkgs package, i.e.:

$ nix-env -qaP coreutils
nixos.coreutils  coreutils-8.23

If your system responds like that (most NixOS installations will), then the attribute path to haskellPackages is nixos.haskellPackages. Thus, if you want to use nix-env without giving an explicit -f flag, then that's the way to do it:

$ nix-env -qaP -A nixos.haskellPackages
$ nix-env -iA nixos.haskellPackages.cabal-install