1 { lib, stdenv, fetchFromGitLab, getopt, lua, boost, libxcrypt, pkg-config, swig, perl, gcc }:
4 self = stdenv.mkDerivation rec {
8 src = fetchFromGitLab {
12 hash = "sha256-UxbgYspocoy9ul2dhIhvIwqKMeWSG7vJY1df3UkgpHQ=";
15 enableParallelBuilding = true;
17 nativeBuildInputs = [ pkg-config swig perl ]
18 ++ lib.optional stdenv.hostPlatform.isDarwin gcc;
20 buildInputs = [ getopt lua boost libxcrypt ];
23 substituteInPlace src/makefile \
24 --replace "shell pkg-config" "shell $PKG_CONFIG"
25 substituteInPlace makefile \
26 --replace 'gzip' 'gzip -n'
27 '' + lib.optionalString stdenv.cc.isClang ''
28 substituteInPlace src/makefile \
29 --replace 'CXX=g++' 'CXX=clang++'
33 makeFlags="PREFIX=$out conf_dir=$out/etc/highlight/ CXX=$CXX AR=$AR"
36 # This has to happen _before_ the main build because it does a
37 # `make clean' for some reason.
38 preBuild = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
39 make -C extras/swig $makeFlags perl
42 postCheck = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
43 perl -Iextras/swig extras/swig/testmod.pl
46 preInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
47 mkdir -p $out/${perl.libPrefix}
48 install -m644 extras/swig/highlight.{so,pm} $out/${perl.libPrefix}
49 make -C extras/swig clean # Clean up intermediate files.
53 description = "Source code highlighting tool";
54 mainProgram = "highlight";
55 homepage = "http://www.andre-simon.de/doku/highlight/en/highlight.php";
56 platforms = platforms.unix;
57 maintainers = with maintainers; [ willibutz ];
62 if stdenv.hostPlatform.isDarwin then self
63 else perl.pkgs.toPerlModule self