haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

error: attribute 'sources' missing -- M1 Mac

Open xave opened this issue 3 years ago • 4 comments

Issue: Following the instructions on the IOHK site fails to build on M1 Mac.

Error Message:

error: attribute 'sources' missing

       at /Users/xavier/Documents/projects/webdev/scotty-site/default.nix:24:5:

           23|     # But you can also just use your own, e.g. '<nixpkgs>'.
           24|     haskellNix.sources.nixpkgs-unstable
             |     ^
           25|     # These arguments passed to nixpkgs, include some patches and also

Steps:

  1. stack new projectname
  2. Set up binary cache in /etc/nix/nix.conf by adding the two lines listed in the instructions.
  3. Didn't install Niv because it won't complete an install.
  4. Used the no-Niv workaround to produce this default.nix with deviations as laid out in the instructions.
let
  ## Read in the Niv sources
  #sources = import ./nix/sources.nix {};
  ## If ./nix/sources.nix file is not found run:
  ##   niv init
  ##   niv add input-output-hk/haskell.nix -n haskellNix

  # Read sources without Niv using pinned ghc
  sources = { 
    haskellNix = builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/f1a94a4c82a2ab999a67c3b84269da78d89f0075.tar.gz";
      };


  # Fetch the haskell.nix commit we have pinned with Niv
  haskellNix = import sources.haskellNix {};
  # If haskellNix is not found run:
  #   niv add input-output-hk/haskell.nix -n haskellNix

  # Import nixpkgs and pass the haskell.nix provided nixpkgsArgs
  pkgs = import
    # haskell.nix provides access to the nixpkgs pins which are used by our CI,
    # hence you will be more likely to get cache hits when using these.
    # But you can also just use your own, e.g. '<nixpkgs>'.
    haskellNix.sources.nixpkgs-unstable
    # These arguments passed to nixpkgs, include some patches and also
    # the haskell.nix functionality itself as an overlay.
    haskellNix.nixpkgsArgs;
in pkgs.haskell-nix.project {
  # 'cleanGit' cleans a source directory based on the files known by git
  src = pkgs.haskell-nix.haskellLib.cleanGit {
    name = "haskell-nix-project";
    src = ./.;
  };
  # Specify the GHC version to use.
  compiler-nix-name = "ghc8102"; # Not required for `stack.yaml` based projects.
}
  1. Ran nix-build -A projectname.components.library on what is at this point a stock Haskell project.
  2. Received the Error Message as listed above.

xave avatar Nov 18 '21 17:11 xave

    haskellNix = builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/f1a94a4c82a2ab999a67c3b84269da78d89f0075.tar.gz";

f1a94a4c82a2ab999a67c3b84269da78d89f0075 is a very old version of haskell.nix. I suspect we might not have updated the commit hash in the docs when the instructions were changed.

Try updating to a more recent haskell.nix commit hash. For instance c810f3af58d6e93d1459315ae26b8d8e4b5c1f3d:

    haskellNix = builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/c810f3af58d6e93d1459315ae26b8d8e4b5c1f3d.tar.gz";

hamishmack avatar Nov 25 '21 01:11 hamishmack

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 28 '22 16:09 stale[bot]

Did using a more recent haskell.nix help?

hamishmack avatar Oct 10 '22 13:10 hamishmack

I stopped using Haskell nix, so I would say not. I am pretty good about trying solutions that people present to me. Perhaps this weekend I can play around with it again.

xave avatar Oct 10 '22 15:10 xave

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 08 '23 00:02 stale[bot]