nixpkgs/pkgs/applications/editors/lite/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

59 lines
1.4 KiB
Nix

{ lib, stdenv
, fetchFromGitHub
, SDL2
, lua52Packages
, pkg-config
, makeWrapper
} :
stdenv.mkDerivation rec {
pname = "lite";
version = "1.11";
src = fetchFromGitHub {
owner = "rxi";
repo = pname;
rev = "v${version}";
sha256 = "0wxqfb4ly8g7w5qph76xys95b55ackkags8jgd1nasmiyi8gcd5a";
};
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 lib; {
description = "A lightweight text editor written in Lua";
homepage = "https://github.com/rxi/lite";
license = licenses.mit;
maintainers = with maintainers; [ Br1ght0ne ];
platforms = platforms.unix;
};
}