haskell.nix
haskell.nix copied to clipboard
When depending on `ghc` on 9.4: "The option `packages.Cabal.package.identifier.name' is used but not defined"
Describe the bug
In a trivial hello world project with GHC 9.4 (ghc944 concretely), depending on the ghc library via build-depends causes evaluation to fail:
error: The option `packages.Cabal.package.identifier.name' is used but not defined.
Full trace
error:
… while evaluating the attribute 'buildInputs' of the derivation 'stuff-exe-stuff-0.1.0.0'
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/pkgs/stdenv/generic/make-derivation.nix:286:7:
285| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
286| name =
| ^
287| let
… while evaluating the attribute 'SETUP_HS' of the derivation 'ghc-lib-ghc-9.4.4'
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/pkgs/stdenv/generic/make-derivation.nix:286:7:
285| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
286| name =
| ^
287| let
… while evaluating the attribute 'buildPhase' of the derivation 'ghc-9.4.4-setup'
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/pkgs/stdenv/generic/make-derivation.nix:286:7:
285| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
286| name =
| ^
287| let
… while evaluating call site
at /nix/store/2kmdzja8283zmm43xw2fgsynl6ki9s0f-source/builder/setup-builder.nix:22:23:
21|
22| includeGhcPackage = lib.any (p: p.identifier.name == "ghc") component.depends;
| ^
23|
… while calling anonymous lambda
at /nix/store/2kmdzja8283zmm43xw2fgsynl6ki9s0f-source/builder/setup-builder.nix:22:32:
21|
22| includeGhcPackage = lib.any (p: p.identifier.name == "ghc") component.depends;
| ^
23|
… while evaluating call site
at «none»:0: (source not available)
… while calling 'g'
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/lib/attrsets.nix:535:19:
534| g =
535| name: value:
| ^
536| if isAttrs value && cond value
… while evaluating call site
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/lib/attrsets.nix:538:20:
537| then recurse (path ++ [name]) value
538| else f (path ++ [name]) value;
| ^
539| in mapAttrs g;
… while calling anonymous lambda
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/lib/modules.nix:270:72:
269| # For definitions that have an associated option
270| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
| ^
271|
… while evaluating the attribute 'value'
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/lib/modules.nix:728:9:
727| in warnDeprecation opt //
728| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
729| inherit (res.defsFinal') highestPrio;
… while evaluating the option `packages.Cabal.package.identifier.name':
… while evaluating the attribute 'mergedValue'
at /nix/store/3qqa3phclva9vjs8zv4ygg9pnadbb6nk-source/lib/modules.nix:763:5:
762| # Type-check the remaining definitions, and merge them. Or throw if no definitions.
763| mergedValue =
| ^
764| if isDefined then
error: The option `packages.Cabal.package.identifier.name' is used but not defined.
Steps To Reproduce
MRE: https://github.com/amesgen/stuff/tree/haskell.nix-ghc94-weirdness
$ nix path-info --derivation github:amesgen/stuff/haskell.nix-ghc94-weirdness
trace: No index state specified for haskell-project, using the latest index state that we know about (2023-02-14T00:00:00Z)!
trace: No index state specified for alex, using the latest index state that we know about (2023-02-14T00:00:00Z)!
trace: No index state specified for happy, using the latest index state that we know about (2023-02-14T00:00:00Z)!
error: The option `packages.Cabal.package.identifier.name' is used but not defined.
Expected behavior
It should compile just fine, as it does on e.g. GHC 9.2.
Additional context
System: x86_64-linux
Just confirming this is still an issue
Just to mention a workaround: Adding Cabal somewhere to the build plan fixes the issue. Seems related to #1836, in particular https://github.com/input-output-hk/haskell.nix/issues/1836#issuecomment-1422269562.
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.
I think this is no longer an issue.