From a120e6098d2b8aa06ac8bfe30a9511e585f930bc Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 10 May 2025 08:26:33 +0200 Subject: [PATCH 1/2] ghc.bootstrapAvailable: init This will give packages that e.g. want to optionally disable pandoc based on availability a simple attribute to check, rather than having to copy quite a complex conditional between packages. --- pkgs/development/compilers/ghc/8.10.7.nix | 2 ++ pkgs/development/compilers/ghc/common-hadrian.nix | 2 ++ pkgs/development/compilers/ghc/common-make-native-bignum.nix | 2 ++ 3 files changed, 6 insertions(+) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index b794cf656b8a..c972f29289d3 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -640,6 +640,8 @@ stdenv.mkDerivation ( # Our Cabal compiler name haskellCompilerName = "ghc-${version}"; + + bootstrapAvailable = lib.meta.availableOn stdenv.buildPlatform bootPkgs.ghc; }; meta = { diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index a78b8a1a90da..b9c58450f261 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -838,6 +838,8 @@ stdenv.mkDerivation ( # TODO(@sternenseemann): there's no stage0:exe:haddock target by default, # so haddock isn't available for GHC cross-compilers. Can we fix that? hasHaddock = stdenv.hostPlatform == stdenv.targetPlatform; + + bootstrapAvailable = lib.meta.availableOn stdenv.buildPlatform bootPkgs.ghc; }; meta = { diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix index 3c236bb4c45d..03ad68c392a1 100644 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ b/pkgs/development/compilers/ghc/common-make-native-bignum.nix @@ -645,6 +645,8 @@ stdenv.mkDerivation ( # Our Cabal compiler name haskellCompilerName = "ghc-${version}"; + + bootstrapAvailable = lib.meta.availableOn stdenv.buildPlatform bootPkgs.ghc; }; meta = { From 14a2f96a7526edbc0923079db6848516a04b1b6f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 6 May 2025 11:32:54 +0200 Subject: [PATCH 2/2] treewide: more accurate pandoc/shellcheck availability checks The actual problem here is that there is no GHC bootstrap tarball for RISC-V or LoongArch, so the right thing to check here is whether the platform being used to build GHC has a bootstrap tarball available for it. This way, we'll do the right thing in all cases where such a tarball isn't available, not just riscv64 and loongarch64, without having to resort to tryEval, which could be hiding all sorts of problems. Since we need to refer to (unspliced) buildPackages.pandoc and buildPackages.shellcheck in the conditionals, I've opted to remove the pandoc and shellcheck inputs that would be spliced in nativeBuildInputs and use buildPackages explicitly there as well, to avoid confusingly having two different instances of the same package around. --- pkgs/build-support/trivial-builders/default.nix | 9 +++------ pkgs/by-name/fl/flac/package.nix | 6 +++--- pkgs/by-name/ni/nixos-firewall-tool/package.nix | 9 +++------ pkgs/development/libraries/gssdp/1.6.nix | 6 +++--- pkgs/development/libraries/nuspell/default.nix | 6 +++--- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index c8a3e4a3a733..a6095316c09a 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -367,17 +367,14 @@ rec { ''; checkPhase = - # GHC (=> shellcheck) isn't supported on some platforms (such as risc-v) - # but we still want to use writeShellApplication on those platforms let - shellcheckSupported = - lib.meta.availableOn stdenv.buildPlatform shellcheck-minimal.compiler - && (builtins.tryEval shellcheck-minimal.compiler.outPath).success; excludeFlags = lib.optionals (excludeShellChecks != [ ]) [ "--exclude" (lib.concatStringsSep "," excludeShellChecks) ]; - shellcheckCommand = lib.optionalString shellcheckSupported '' + # GHC (=> shellcheck) isn't supported on some platforms (such as risc-v) + # but we still want to use writeShellApplication on those platforms + shellcheckCommand = lib.optionalString shellcheck-minimal.compiler.bootstrapAvailable '' # use shellcheck which does not include docs # pandoc takes long to build and documentation isn't needed for just running the cli ${lib.getExe shellcheck-minimal} ${ diff --git a/pkgs/by-name/fl/flac/package.nix b/pkgs/by-name/fl/flac/package.nix index 7e4c6fcaca50..d42ca2a679fa 100644 --- a/pkgs/by-name/fl/flac/package.nix +++ b/pkgs/by-name/fl/flac/package.nix @@ -6,11 +6,11 @@ lib, libogg, nix-update-script, - pandoc, + buildPackages, pkg-config, stdenv, versionCheckHook, - enableManpages ? !stdenv.buildPlatform.isRiscV64 && !stdenv.buildPlatform.isLoongArch64, + enableManpages ? buildPackages.pandoc.compiler.bootstrapAvailable, }: stdenv.mkDerivation (finalAttrs: { pname = "flac"; @@ -30,7 +30,7 @@ stdenv.mkDerivation (finalAttrs: { doxygen graphviz pkg-config - ] ++ lib.optional enableManpages pandoc; + ] ++ lib.optional enableManpages buildPackages.pandoc; buildInputs = [ libogg ]; diff --git a/pkgs/by-name/ni/nixos-firewall-tool/package.nix b/pkgs/by-name/ni/nixos-firewall-tool/package.nix index b928487c5277..13f27d3b7b25 100644 --- a/pkgs/by-name/ni/nixos-firewall-tool/package.nix +++ b/pkgs/by-name/ni/nixos-firewall-tool/package.nix @@ -3,7 +3,7 @@ lib, bash, installShellFiles, - shellcheck-minimal, + buildPackages, }: stdenvNoCC.mkDerivation { @@ -14,7 +14,7 @@ stdenvNoCC.mkDerivation { strictDeps = true; buildInputs = [ bash ]; nativeBuildInputs = [ installShellFiles ]; - nativeCheckInputs = [ shellcheck-minimal ]; + nativeCheckInputs = [ buildPackages.shellcheck-minimal ]; postPatch = '' patchShebangs --host nixos-firewall-tool @@ -26,10 +26,7 @@ stdenvNoCC.mkDerivation { installShellCompletion nixos-firewall-tool.{bash,fish} ''; - # Skip shellcheck if GHC is not available, see writeShellApplication. - doCheck = - lib.meta.availableOn stdenvNoCC.buildPlatform shellcheck-minimal.compiler - && (builtins.tryEval shellcheck-minimal.compiler.outPath).success; + doCheck = buildPackages.shellcheck-minimal.compiler.bootstrapAvailable; checkPhase = '' shellcheck nixos-firewall-tool ''; diff --git a/pkgs/development/libraries/gssdp/1.6.nix b/pkgs/development/libraries/gssdp/1.6.nix index 04fe20f2d477..caab2b7c865d 100644 --- a/pkgs/development/libraries/gssdp/1.6.nix +++ b/pkgs/development/libraries/gssdp/1.6.nix @@ -7,8 +7,8 @@ pkg-config, gobject-introspection, vala, - enableManpages ? !stdenv.buildPlatform.isLoongArch64 && !stdenv.buildPlatform.isRiscV64, - pandoc, + buildPackages, + enableManpages ? buildPackages.pandoc.compiler.bootstrapAvailable, gi-docgen, python3, libsoup_3, @@ -44,7 +44,7 @@ stdenv.mkDerivation rec { vala gi-docgen python3 - ] ++ lib.optionals enableManpages [ pandoc ]; + ] ++ lib.optionals enableManpages [ buildPackages.pandoc ]; buildInputs = [ libsoup_3 diff --git a/pkgs/development/libraries/nuspell/default.nix b/pkgs/development/libraries/nuspell/default.nix index a4c5bc0813e7..92a9a6b0e399 100644 --- a/pkgs/development/libraries/nuspell/default.nix +++ b/pkgs/development/libraries/nuspell/default.nix @@ -3,11 +3,11 @@ stdenv, fetchFromGitHub, cmake, - pandoc, + buildPackages, pkg-config, icu, catch2_3, - enableManpages ? !stdenv.buildPlatform.isRiscV64 && !stdenv.buildPlatform.isLoongArch64, + enableManpages ? buildPackages.pandoc.compiler.bootstrapAvailable, }: stdenv.mkDerivation rec { @@ -27,7 +27,7 @@ stdenv.mkDerivation rec { pkg-config ] ++ lib.optionals enableManpages [ - pandoc + buildPackages.pandoc ]; buildInputs = [ catch2_3 ];