haskell.nix
haskell.nix copied to clipboard
error: attribute 'sources' missing -- M1 Mac
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:
-
stack new projectname
- Set up binary cache in
/etc/nix/nix.conf
by adding the two lines listed in the instructions. - Didn't install Niv because it won't complete an install.
- 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.
}
- Ran
nix-build -A projectname.components.library
on what is at this point a stock Haskell project. - Received the Error Message as listed above.
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";
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.
Did using a more recent haskell.nix help?
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.
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.