Skip to content

Commit

Permalink
writeShellApplication: use shellcheck only where supported
Browse files Browse the repository at this point in the history
  • Loading branch information
fgaz committed Jul 19, 2023
1 parent 1760dc9 commit fed2c13
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions pkgs/build-support/trivial-builders/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, stdenvNoCC, lndir, runtimeShell, shellcheck, haskell }:
{ lib, stdenv, stdenvNoCC, lndir, runtimeShell, shellcheck, haskell, ghc }:

let
inherit (lib)
Expand Down Expand Up @@ -347,12 +347,20 @@ 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 = (builtins.tryEval ghc.bootPkgs.ghc).success;
shellcheckCommand = lib.optionalString shellcheckSupported ''
# use shellcheck which does not include docs
# pandoc takes long to build and documentation isn't needed for just running the cli
${lib.getExe (haskell.lib.compose.justStaticExecutables shellcheck.unwrapped)} "$target"
'';
in
if checkPhase == null then ''
runHook preCheck
${stdenv.shellDryRun} "$target"
# use shellcheck which does not include docs
# pandoc takes long to build and documentation isn't needed for in nixpkgs usage
${lib.getExe (haskell.lib.compose.justStaticExecutables shellcheck.unwrapped)} "$target"
${shellcheckCommand}
runHook postCheck
''
else checkPhase;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/stage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ let
trivialBuilders = self: super:
import ../build-support/trivial-builders {
inherit lib;
inherit (self) runtimeShell stdenv stdenvNoCC haskell;
inherit (self) runtimeShell stdenv stdenvNoCC haskell ghc;
inherit (self.pkgsBuildHost) shellcheck;
inherit (self.pkgsBuildHost.xorg) lndir;
};
Expand Down

0 comments on commit fed2c13

Please sign in to comment.