Nix and Haskell-ng install error : attribute ‘nixpkgs’ in selection path ‘nixpkgs.haskellEnv’ not found
Asked Answered
L

1

9

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?

Lemuelah answered 20/6, 2015 at 8:41 Comment(3)
I'm currently re-trying based on this: nixos.org/wiki/Nix_on_OS_X#Using_Nix_on_10.9_and_10.10, also maybe I made some simple mistakes.Lemuelah
OK, so it seems to work now.Lemuelah
It has been compiling stuff for 1 hour now, what is it doing so long and why?Lemuelah
A
11

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
Abrahamsen answered 19/11, 2015 at 15:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.