summary refs log tree commit diff
path: root/pkgs/development/tools/shellcheck/default.nix
blob: 568b9e1e1dddc829b012ddb83b93265859e66f46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{ stdenv, lib, haskellPackages, 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.justStaticExecutables haskellPackages.ShellCheck;

  shellcheck = stdenv.mkDerivation {
    pname = "shellcheck";
    version = bin.version;

    inherit (haskellPackages.ShellCheck) meta src;

    nativeBuildInputs = [ pandoc ];

    outputs = [ "bin" "man" "doc" "out" ];

    phases = [ "unpackPhase" "buildPhase" "installPhase" "fixupPhase" ];

    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
    '';
  };

in
  overrideMeta shellcheck (old: {
    maintainers = with lib.maintainers; [ Profpatsch ];
    outputsToInstall = [ "bin" "man" "doc" ];
  })