Commit bf388d55 authored by sternenseemann's avatar sternenseemann
Browse files

haskell.compiler.ghc*Binary: make sure meta can always be evaluated

The `meta` set of the binary GHCs is mostly independent of the used
bindist (except for `pname` which includes `variantSuffix`). Thus we
should make sure it can be evaluated even if no bindist is available for
the platform, i.e. evaluating `outPath` may cause an evaluation failure,
but `meta.platforms` not. Use case at present is to make
`lib.meta.availableOn` work everywhere for any GHC (the normal GHCs
inherit their platforms list from their respective boot compiler, at
least for now).

To fix this we need to make sure that shallowly evaluating `passthru`
doesn't force `binDistUsed`, since `mkDerivation` needs to merge
`passthru` into the resulting derivation attribute set, thus forcing the
attribute names of `passthru`. We can easily do this by accessing what
we want to learn from `ghcBinDists` manually and using `or` to fall back
to a sensible default.
parent 54a572ac
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -421,7 +421,10 @@ stdenv.mkDerivation rec {

    # Our Cabal compiler name
    haskellCompilerName = "ghc-${version}";
  } // lib.optionalAttrs (binDistUsed.isHadrian or false) {
  }
  # We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible,
  # this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
  // lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) {
    # Normal GHC derivations expose the hadrian derivation used to build them
    # here. In the case of bindists we just make sure that the attribute exists,
    # as it is used for checking if a GHC derivation has been built with hadrian.
+4 −1
Original line number Diff line number Diff line
@@ -417,7 +417,10 @@ stdenv.mkDerivation rec {

    # Our Cabal compiler name
    haskellCompilerName = "ghc-${version}";
  } // lib.optionalAttrs (binDistUsed.isHadrian or false) {
  }
  # We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible,
  # this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
  // lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) {
    # Normal GHC derivations expose the hadrian derivation used to build them
    # here. In the case of bindists we just make sure that the attribute exists,
    # as it is used for checking if a GHC derivation has been built with hadrian.
+4 −1
Original line number Diff line number Diff line
@@ -403,7 +403,10 @@ stdenv.mkDerivation rec {

    # Our Cabal compiler name
    haskellCompilerName = "ghc-${version}";
  } // lib.optionalAttrs (binDistUsed.isHadrian or false) {
  }
  # We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible,
  # this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
  // lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) {
    # Normal GHC derivations expose the hadrian derivation used to build them
    # here. In the case of bindists we just make sure that the attribute exists,
    # as it is used for checking if a GHC derivation has been built with hadrian.