summary refs log tree commit diff
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2020-03-06 08:48:56 +0100
committerProfpatsch <mail@profpatsch.de>2020-03-06 09:20:12 +0100
commit0bc0c10a78fa1af651cbfb50503101e231634d46 (patch)
treed19e1daa2d09011c1b605b4809da21d221d99416
parent53ae5f76a20257a61e231f250196066a7d0667bc (diff)
downloadnixpkgs-0bc0c10a78fa1af651cbfb50503101e231634d46.tar
nixpkgs-0bc0c10a78fa1af651cbfb50503101e231634d46.tar.gz
nixpkgs-0bc0c10a78fa1af651cbfb50503101e231634d46.tar.bz2
nixpkgs-0bc0c10a78fa1af651cbfb50503101e231634d46.tar.lz
nixpkgs-0bc0c10a78fa1af651cbfb50503101e231634d46.tar.xz
nixpkgs-0bc0c10a78fa1af651cbfb50503101e231634d46.tar.zst
nixpkgs-0bc0c10a78fa1af651cbfb50503101e231634d46.zip
shellcheck: add manpage and docs
The shellcheck source code contains a manpage, so let’s add that to
the output. For good measure, also copy the README to the doc output.

The overrideMeta thing is taking care of setting the right position,
so that `nix edit` points to this file instead of to the original
haskellPackages definition.
-rw-r--r--pkgs/development/tools/shellcheck/default.nix47
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 48 insertions, 1 deletions
diff --git a/pkgs/development/tools/shellcheck/default.nix b/pkgs/development/tools/shellcheck/default.nix
new file mode 100644
index 00000000000..ca3e801e3ed
--- /dev/null
+++ b/pkgs/development/tools/shellcheck/default.nix
@@ -0,0 +1,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" ];
+  })
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 5574d0cc76a..cfefb2ca6f6 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -10646,7 +10646,7 @@ in
 
   shards = callPackage ../development/tools/build-managers/shards { };
 
-  shellcheck = haskell.lib.justStaticExecutables haskellPackages.ShellCheck;
+  shellcheck = callPackage ../development/tools/shellcheck {};
 
   schemaspy = callPackage ../development/tools/database/schemaspy { };