summary refs log tree commit diff
path: root/pkgs/development/tools/shellcheck/default.nix
blob: ca3e801e3ed1036561b01974a9125b9848dee75d (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
{ stdenv, lib, haskellPackages, haskell }:

# 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;
  src = haskellPackages.ShellCheck.src;

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

    inherit src;

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

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

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

    # just some file copying
    preferLocalBuild = true;
    allowSubstitutes = false;
  };

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