summary refs log tree commit diff
path: root/pkgs/applications/editors/lite
diff options
context:
space:
mode:
authorPavol Rusnak <pavol@rusnak.io>2020-05-09 23:30:57 +0200
committerPavol Rusnak <pavol@rusnak.io>2020-05-11 22:46:40 +0200
commit15a2a6d3107822943a778423b801c65fc01dbae5 (patch)
tree8469bd45df54dc33dbfdcf03180fb69731582a4a /pkgs/applications/editors/lite
parent84982d16646e815b17af8f4bbd34d70b6ace815e (diff)
downloadnixpkgs-15a2a6d3107822943a778423b801c65fc01dbae5.tar
nixpkgs-15a2a6d3107822943a778423b801c65fc01dbae5.tar.gz
nixpkgs-15a2a6d3107822943a778423b801c65fc01dbae5.tar.bz2
nixpkgs-15a2a6d3107822943a778423b801c65fc01dbae5.tar.lz
nixpkgs-15a2a6d3107822943a778423b801c65fc01dbae5.tar.xz
nixpkgs-15a2a6d3107822943a778423b801c65fc01dbae5.tar.zst
nixpkgs-15a2a6d3107822943a778423b801c65fc01dbae5.zip
lite: init at 1.03
Diffstat (limited to 'pkgs/applications/editors/lite')
-rw-r--r--pkgs/applications/editors/lite/default.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/pkgs/applications/editors/lite/default.nix b/pkgs/applications/editors/lite/default.nix
new file mode 100644
index 00000000000..107be433832
--- /dev/null
+++ b/pkgs/applications/editors/lite/default.nix
@@ -0,0 +1,58 @@
+{ stdenv
+, fetchFromGitHub
+, SDL2
+, lua52Packages
+, pkg-config
+, makeWrapper
+} :
+
+stdenv.mkDerivation rec {
+  pname = "lite";
+  version = "1.03";
+
+  src = fetchFromGitHub {
+    owner = "rxi";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1h8z4fav5ns9sm92axs3k9v6jgkqq0vg9mixza14949blr426mlj";
+  };
+
+  nativeBuildInputs = [ makeWrapper pkg-config ];
+
+  buildInputs = [ SDL2 lua52Packages.lua ];
+
+  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)"
+    LDFLAGS="$(pkg-config --libs lua sdl2)"
+    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
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A lightweight text editor written in Lua";
+    homepage = "https://github.com/rxi/lite";
+    license = licenses.mit;
+    maintainers = with maintainers; [ filalex77 ];
+    platforms = platforms.unix;
+  };
+}