1{ stdenv, lib, haskellPackages, haskell, pandoc }:
2
3# this wraps around the haskell package
4# and puts the documentation into place
5
6let
7 # TODO: move to lib/ in separate PR
8 overrideMeta = drv: overrideFn:
9 let
10 drv' = if drv ? meta then drv else drv // { meta = {}; };
11 pos = (builtins.unsafeGetAttrPos "pname" drv');
12 meta' = drv'.meta // {
13 # copied from the mkDerivation code
14 position = pos.file + ":" + toString pos.line;
15 };
16 in drv' // { meta = meta' // overrideFn meta'; };
17
18 bin = haskell.lib.compose.justStaticExecutables haskellPackages.ShellCheck;
19
20 shellcheck = stdenv.mkDerivation {
21 pname = "shellcheck";
22 version = bin.version;
23
24 inherit (haskellPackages.ShellCheck) meta src;
25
26 nativeBuildInputs = [ pandoc ];
27
28 outputs = [ "bin" "man" "doc" "out" ];
29
30 buildPhase = ''
31 pandoc -s -f markdown-smart -t man shellcheck.1.md -o shellcheck.1
32 '';
33
34 installPhase = ''
35 install -Dm755 ${bin}/bin/shellcheck $bin/bin/shellcheck
36 install -Dm644 README.md $doc/share/shellcheck/README.md
37 install -Dm644 shellcheck.1 $man/share/man/man1/shellcheck.1
38 mkdir $out
39 '';
40 };
41
42in
43 overrideMeta shellcheck (old: {
44 maintainers = with lib.maintainers; [ Profpatsch ];
45 outputsToInstall = [ "bin" "man" "doc" ];
46 })