3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/shellcheck/default.nix
Artturin 62e1d58a6f trivial-builders.writeShellApplication: use unwrapped pandoc
writeShellApplication does not need shellcheck docs

it takes ~1 hour to compile the dependencies of pandoc on r9 5900x
because haskell is so slow

$ nix path-info -r ".#sway" --derivation | wc -l
2357

$ nix path-info -r ".#sway" --derivation | wc -l
2055
2022-12-13 05:39:58 +02:00

52 lines
1.4 KiB
Nix

{ stdenv, lib, ShellCheck, haskell, pandoc }:
# this wraps around the haskell package
# and puts the documentation into place
let
# TODO: move to lib/ in separate PR
overrideMeta = drv: overrideFn:
let
drv' = if drv ? meta then drv else drv // { meta = {}; };
pos = (builtins.unsafeGetAttrPos "pname" drv');
meta' = drv'.meta // {
# copied from the mkDerivation code
position = pos.file + ":" + toString pos.line;
};
in drv' // { meta = meta' // overrideFn meta'; };
bin = haskell.lib.compose.justStaticExecutables ShellCheck;
shellcheck = stdenv.mkDerivation {
pname = "shellcheck";
version = bin.version;
inherit (ShellCheck) meta src;
nativeBuildInputs = [ pandoc ];
outputs = [ "bin" "man" "doc" "out" ];
buildPhase = ''
pandoc -s -f markdown-smart -t man shellcheck.1.md -o shellcheck.1
'';
installPhase = ''
install -Dm755 ${bin}/bin/shellcheck $bin/bin/shellcheck
install -Dm644 README.md $doc/share/shellcheck/README.md
install -Dm644 shellcheck.1 $man/share/man/man1/shellcheck.1
mkdir $out
'';
passthru = ShellCheck.passthru or {} // {
# pandoc takes long to build and documentation isn't needed for in nixpkgs usage
unwrapped = ShellCheck;
};
};
in
overrideMeta shellcheck (old: {
maintainers = with lib.maintainers; [ Profpatsch ];
outputsToInstall = [ "bin" "man" "doc" ];
})