lol
1{
2 lib,
3 stdenv,
4 rustPlatform,
5 fetchFromGitHub,
6 cargo,
7 capstone,
8 libbfd,
9 libelf,
10 libiberty,
11 readline,
12}:
13
14stdenv.mkDerivation (finalAttrs: {
15 pname = "wcc";
16 version = "0.0.11";
17
18 src = fetchFromGitHub {
19 owner = "endrazine";
20 repo = "wcc";
21 tag = "v${finalAttrs.version}";
22 hash = "sha256-hyelDAsE3IFvUxBqttYW7QmM6NPEa6pOREmawFjW2Q8=";
23 deepClone = true;
24 fetchSubmodules = true;
25 };
26
27 cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
28
29 nativeBuildInputs = [
30 cargo
31 rustPlatform.cargoSetupHook
32 ];
33
34 buildInputs = [
35 capstone
36 libbfd
37 libelf
38 libiberty
39 readline
40 ];
41
42 postPatch = ''
43 cp ${./Cargo.lock} Cargo.lock
44 sed -i src/wsh/include/libwitch/wsh.h src/wsh/scripts/INDEX \
45 -e "s#/usr/share/wcc#$out/share/wcc#"
46
47 sed -i -e '/stropts.h>/d' src/wsh/include/libwitch/wsh.h
48
49 sed -i '/wsh-static/d' src/wsh/Makefile
50 '';
51
52 env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
53
54 installFlags = [ "DESTDIR=$(out)" ];
55
56 preInstall = ''
57 mkdir -p $out/usr/bin $out/lib/x86_64-linux-gnu
58 '';
59
60 postInstall = ''
61 mv $out/usr/* $out
62 rmdir $out/usr
63 mkdir -p $out/share/man/man1
64 cp doc/manpages/*.1 $out/share/man/man1/
65 '';
66
67 postFixup = ''
68 # not detected by patchShebangs
69 substituteInPlace $out/bin/wcch --replace-fail '#!/usr/bin/wsh' "#!$out/bin/wsh"
70 '';
71
72 enableParallelBuilding = true;
73
74 meta = {
75 homepage = "https://github.com/endrazine/wcc";
76 description = "Witchcraft compiler collection: tools to convert and script ELF files";
77 license = lib.licenses.mit;
78 platforms = [
79 "x86_64-linux"
80 "aarch64-linux"
81 ];
82 maintainers = with lib.maintainers; [
83 orivej
84 DieracDelta
85 ];
86 };
87})