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.
This commit is contained in:
Alyssa Ross 2025-05-06 11:32:54 +02:00
parent a120e6098d
commit 14a2f96a75
No known key found for this signature in database
GPG key ID: 5B459184230FF0A2
5 changed files with 15 additions and 21 deletions

View file

@ -367,17 +367,14 @@ rec {
''; '';
checkPhase = checkPhase =
# GHC (=> shellcheck) isn't supported on some platforms (such as risc-v)
# but we still want to use writeShellApplication on those platforms
let let
shellcheckSupported =
lib.meta.availableOn stdenv.buildPlatform shellcheck-minimal.compiler
&& (builtins.tryEval shellcheck-minimal.compiler.outPath).success;
excludeFlags = lib.optionals (excludeShellChecks != [ ]) [ excludeFlags = lib.optionals (excludeShellChecks != [ ]) [
"--exclude" "--exclude"
(lib.concatStringsSep "," excludeShellChecks) (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 # use shellcheck which does not include docs
# pandoc takes long to build and documentation isn't needed for just running the cli # pandoc takes long to build and documentation isn't needed for just running the cli
${lib.getExe shellcheck-minimal} ${ ${lib.getExe shellcheck-minimal} ${

View file

@ -6,11 +6,11 @@
lib, lib,
libogg, libogg,
nix-update-script, nix-update-script,
pandoc, buildPackages,
pkg-config, pkg-config,
stdenv, stdenv,
versionCheckHook, versionCheckHook,
enableManpages ? !stdenv.buildPlatform.isRiscV64 && !stdenv.buildPlatform.isLoongArch64, enableManpages ? buildPackages.pandoc.compiler.bootstrapAvailable,
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "flac"; pname = "flac";
@ -30,7 +30,7 @@ stdenv.mkDerivation (finalAttrs: {
doxygen doxygen
graphviz graphviz
pkg-config pkg-config
] ++ lib.optional enableManpages pandoc; ] ++ lib.optional enableManpages buildPackages.pandoc;
buildInputs = [ libogg ]; buildInputs = [ libogg ];

View file

@ -3,7 +3,7 @@
lib, lib,
bash, bash,
installShellFiles, installShellFiles,
shellcheck-minimal, buildPackages,
}: }:
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
@ -14,7 +14,7 @@ stdenvNoCC.mkDerivation {
strictDeps = true; strictDeps = true;
buildInputs = [ bash ]; buildInputs = [ bash ];
nativeBuildInputs = [ installShellFiles ]; nativeBuildInputs = [ installShellFiles ];
nativeCheckInputs = [ shellcheck-minimal ]; nativeCheckInputs = [ buildPackages.shellcheck-minimal ];
postPatch = '' postPatch = ''
patchShebangs --host nixos-firewall-tool patchShebangs --host nixos-firewall-tool
@ -26,10 +26,7 @@ stdenvNoCC.mkDerivation {
installShellCompletion nixos-firewall-tool.{bash,fish} installShellCompletion nixos-firewall-tool.{bash,fish}
''; '';
# Skip shellcheck if GHC is not available, see writeShellApplication. doCheck = buildPackages.shellcheck-minimal.compiler.bootstrapAvailable;
doCheck =
lib.meta.availableOn stdenvNoCC.buildPlatform shellcheck-minimal.compiler
&& (builtins.tryEval shellcheck-minimal.compiler.outPath).success;
checkPhase = '' checkPhase = ''
shellcheck nixos-firewall-tool shellcheck nixos-firewall-tool
''; '';

View file

@ -7,8 +7,8 @@
pkg-config, pkg-config,
gobject-introspection, gobject-introspection,
vala, vala,
enableManpages ? !stdenv.buildPlatform.isLoongArch64 && !stdenv.buildPlatform.isRiscV64, buildPackages,
pandoc, enableManpages ? buildPackages.pandoc.compiler.bootstrapAvailable,
gi-docgen, gi-docgen,
python3, python3,
libsoup_3, libsoup_3,
@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
vala vala
gi-docgen gi-docgen
python3 python3
] ++ lib.optionals enableManpages [ pandoc ]; ] ++ lib.optionals enableManpages [ buildPackages.pandoc ];
buildInputs = [ buildInputs = [
libsoup_3 libsoup_3

View file

@ -3,11 +3,11 @@
stdenv, stdenv,
fetchFromGitHub, fetchFromGitHub,
cmake, cmake,
pandoc, buildPackages,
pkg-config, pkg-config,
icu, icu,
catch2_3, catch2_3,
enableManpages ? !stdenv.buildPlatform.isRiscV64 && !stdenv.buildPlatform.isLoongArch64, enableManpages ? buildPackages.pandoc.compiler.bootstrapAvailable,
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
pkg-config pkg-config
] ]
++ lib.optionals enableManpages [ ++ lib.optionals enableManpages [
pandoc buildPackages.pandoc
]; ];
buildInputs = [ catch2_3 ]; buildInputs = [ catch2_3 ];