From c4edb10662ca7035d8527d09d0d8feb0c541f34e Mon Sep 17 00:00:00 2001
From: Orivej Desh <orivej@gmx.fr>
Date: Wed, 4 Jul 2018 11:02:02 +0000
Subject: [PATCH] wcc: init unstable at 2018-04-05

---
 pkgs/development/compilers/wcc/default.nix | 49 ++++++++++++++++++++++
 pkgs/top-level/all-packages.nix            |  2 +
 2 files changed, 51 insertions(+)
 create mode 100644 pkgs/development/compilers/wcc/default.nix

diff --git a/pkgs/development/compilers/wcc/default.nix b/pkgs/development/compilers/wcc/default.nix
new file mode 100644
index 000000000000..8cb1e8e5f2cd
--- /dev/null
+++ b/pkgs/development/compilers/wcc/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchFromGitHub, capstone, libbfd, libelf, libiberty, readline }:
+
+stdenv.mkDerivation rec {
+  name = "wcc-unstable-${version}";
+  version = "2018-04-05";
+
+  src = fetchFromGitHub {
+    owner = "endrazine";
+    repo = "wcc";
+    rev = "f141963ff193d7e1931d41acde36d20d7221e74f";
+    sha256 = "1f0w869x0176n5nsq7m70r344gv5qvfmk7b58syc0jls8ghmjvb4";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [ capstone libbfd libelf libiberty readline ];
+
+  postPatch = ''
+    sed -i src/wsh/include/libwitch/wsh.h src/wsh/scripts/INDEX \
+      -e "s#/usr/share/wcc#$out/share/wcc#"
+  '';
+
+  installFlags = [ "DESTDIR=$(out)" ];
+
+  preInstall = ''
+    mkdir -p $out/usr/bin
+  '';
+
+  postInstall = ''
+    mv $out/usr/* $out
+    rmdir $out/usr
+    mkdir -p $out/share/man/man1
+    cp doc/manpages/*.1 $out/share/man/man1/
+  '';
+
+  preFixup = ''
+    # Let patchShebangs rewrite shebangs with wsh.
+    PATH+=:$out/bin
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/endrazine/wcc;
+    description = "Witchcraft compiler collection: tools to convert and script ELF files";
+    license = licenses.mit;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ orivej ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 31eba454ec7d..7544aa330647 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7113,6 +7113,8 @@ with pkgs;
 
   valadoc = callPackage ../development/tools/valadoc { };
 
+  wcc = callPackage ../development/compilers/wcc { };
+
   wla-dx = callPackage ../development/compilers/wla-dx { };
 
   wrapCCWith =