Description
I've been trying to set up a nix-shell for a stack project, and no matter what I try to do, it fails with the same message:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:34:12:
33|
34| strict = derivationStrict drvAttrs;
| ^
35|
… while evaluating derivation 'ghc-shell-for-example'
whose name attribute is located at /nix/store/3dkd7jjg354lylv9s5lm3387f4yfls7y-source/pkgs/stdenv/generic/make-derivation.nix:333:7
… while evaluating attribute 'nativeBuildInputs' of derivation 'ghc-shell-for-example'
at /nix/store/3dkd7jjg354lylv9s5lm3387f4yfls7y-source/pkgs/stdenv/generic/make-derivation.nix:377:7:
376| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
377| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
378| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
… while evaluating the option `packages.hruby.components.library.pkgconfig':
… while evaluating definitions from `/nix/store/kk5jv9cbl9xd97al28qg4n3wjv8kwrxg-source/modules/plan.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: The pkg-conf packages does not contain the package: ruby (pkg-conf dependency).
You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found.
It is noteworthy that I am not depending on hruby
in any way shape or form.
In trying to debug this I found out I get this error even on an empty project, across multiple haskell.nix versions, multiple nixpkgs versions, and multiple stackage resolvers.
Here's my empty project:
stack.yaml
:
resolver: lts-22.36
packages:
- example
default.nix
:
let
haskellNix = import (builtins.fetchTarball
"https://github.com/input-output-hk/haskell.nix/archive/a0283c855a38ed70ba521f7a9290e78488ddf11b.tar.gz")
{ };
pkgs = import haskellNix.sources.nixpkgs-2405 haskellNix.nixpkgsArgs;
project = pkgs.haskell-nix.stackProject {
compiler-nix-name = "ghc966";
stackYaml = "stack.yaml";
src = pkgs.haskell-nix.haskellLib.cleanGit {
name = "nix-test";
src = ./.;
};
};
in project
shell.nix
(import ./default.nix).shellFor {
packages = ps: [ ps.example ];
}
The complete MWE repo can be found at: https://github.com/mniip/nix-test
nix-build
runs just fine, but nix-shell
fails with the aforementioned error. All of this happening on x86_64-linux
(not NixOS).
It is my understanding that by pinning a specific haskell.nix tarball I'm also pinning a specific nixpkgs version, so this should be reproducible on any nix machine?
At first I thought this is a legitimate issue with pkg-config, and after a lot of staring at https://input-output-hk.github.io/haskell.nix/tutorials/pkg-map.html (I gotta say, the docs are not super clear about what exactly I need to do), I managed to produce the correct incantation for my default.nix
:
pkgs = (import haskellNix.sources.nixpkgs-2405 haskellNix.nixpkgsArgs).extend
(self: super: {
haskell-nix = super.haskell-nix // {
extraPkgconfigMappings = super.haskell-nix.extraPkgconfigMappings // {
ruby = [ "ruby" ];
};
};
});
After which, it stops complaining about hruby
and now complains about llvm-hs
, which once again I am not depending on:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:34:12:
33|
34| strict = derivationStrict drvAttrs;
| ^
35|
… while evaluating derivation 'ghc-shell-for-example'
whose name attribute is located at /nix/store/3dkd7jjg354lylv9s5lm3387f4yfls7y-source/pkgs/stdenv/generic/make-derivation.nix:333:7
… while evaluating attribute 'nativeBuildInputs' of derivation 'ghc-shell-for-example'
at /nix/store/3dkd7jjg354lylv9s5lm3387f4yfls7y-source/pkgs/stdenv/generic/make-derivation.nix:377:7:
376| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
377| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
378| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
… while evaluating the option `packages.llvm-hs.package.identifier.version':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: The option `packages.llvm-hs.package.identifier.version' is used but not defined.
All of which leads me to conclude that somehow it's trying to evaluate every haskell package in existence even if I'm not using it, and some of them have random failures like this.