From bf388d55142f320b67accf14ff7103c370397515 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Wed, 2 Aug 2023 12:30:10 +0200 Subject: [PATCH] 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. --- pkgs/development/compilers/ghc/8.10.2-binary.nix | 5 ++++- pkgs/development/compilers/ghc/8.10.7-binary.nix | 5 ++++- pkgs/development/compilers/ghc/9.2.4-binary.nix | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.2-binary.nix b/pkgs/development/compilers/ghc/8.10.2-binary.nix index 41461a26d425..368bc76bf0e2 100644 --- a/pkgs/development/compilers/ghc/8.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.2-binary.nix @@ -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. diff --git a/pkgs/development/compilers/ghc/8.10.7-binary.nix b/pkgs/development/compilers/ghc/8.10.7-binary.nix index 22552fa67fb2..73ce0c918574 100644 --- a/pkgs/development/compilers/ghc/8.10.7-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.7-binary.nix @@ -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. diff --git a/pkgs/development/compilers/ghc/9.2.4-binary.nix b/pkgs/development/compilers/ghc/9.2.4-binary.nix index 79b006ce5537..93380fd14519 100644 --- a/pkgs/development/compilers/ghc/9.2.4-binary.nix +++ b/pkgs/development/compilers/ghc/9.2.4-binary.nix @@ -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.