2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv
|
2020-05-09 23:30:57 +02:00
|
|
|
, fetchFromGitHub
|
|
|
|
, SDL2
|
|
|
|
, lua52Packages
|
|
|
|
, pkg-config
|
|
|
|
, makeWrapper
|
2021-05-22 19:08:01 +02:00
|
|
|
, openlibm
|
2020-05-09 23:30:57 +02:00
|
|
|
} :
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "lite";
|
2020-08-02 07:57:03 +02:00
|
|
|
version = "1.11";
|
2020-05-09 23:30:57 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "rxi";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2020-08-02 07:57:03 +02:00
|
|
|
sha256 = "0wxqfb4ly8g7w5qph76xys95b55ackkags8jgd1nasmiyi8gcd5a";
|
2020-05-09 23:30:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper pkg-config ];
|
|
|
|
|
2021-05-22 19:08:01 +02:00
|
|
|
buildInputs = [ SDL2 lua52Packages.lua openlibm ];
|
2020-05-09 23:30:57 +02:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# use system Lua 5.2
|
|
|
|
rm -rf src/lib/lua52
|
|
|
|
substituteInPlace src/api/api.h \
|
|
|
|
--replace '"lib/lua52/lua.h"' '<lua.h>' \
|
|
|
|
--replace '"lib/lua52/lauxlib.h"' '<lauxlib.h>' \
|
|
|
|
--replace '"lib/lua52/lualib.h"' '<lualib.h>'
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
# extracted and adapted from build.sh
|
|
|
|
CC=$NIX_CC/bin/cc
|
|
|
|
CFLAGS="-Wall -O3 -g -std=gnu11 -Isrc -DLUA_USE_POPEN $(pkg-config --cflags lua sdl2)"
|
2021-05-22 19:08:01 +02:00
|
|
|
LDFLAGS="$(pkg-config --libs lua sdl2 openlibm)"
|
2020-05-09 23:30:57 +02:00
|
|
|
for f in $(find src -name "*.c"); do
|
|
|
|
$CC -c $CFLAGS $f -o "''${f//\//_}.o"
|
|
|
|
done
|
|
|
|
$CC *.o $LDFLAGS -o lite
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/lib/${pname}
|
|
|
|
cp -a lite $out/lib/${pname}
|
|
|
|
cp -a data $out/lib/${pname}
|
|
|
|
makeWrapper $out/lib/${pname}/lite $out/bin/lite
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2020-05-09 23:30:57 +02:00
|
|
|
description = "A lightweight text editor written in Lua";
|
|
|
|
homepage = "https://github.com/rxi/lite";
|
|
|
|
license = licenses.mit;
|
2020-11-17 12:02:06 +01:00
|
|
|
maintainers = with maintainers; [ Br1ght0ne ];
|
2020-05-09 23:30:57 +02:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|