nixpkgs/pkgs/applications/window-managers/awesome/default.nix
Stefano Mazzucco c973e15fb6 awesome: refactor LUA_PATH env var and don't expose it at runtime
This commit partly reinstates changes from 5465d6f that had been somehow
reverted in 17d3eb2.  Also, a comment has been added in the hope that future
changes won't do the same.

Additionally, refactor the LUA_PATH env var to ensure that the internal lgi lua
files can't be required explicitly and to avoid possible name clashes (this
fixes issue #60232).

Finally, rather than using prepending `?.lua` append `;;` to LUA_PATH. Quoting
@psychon:

> This is interpreted by Lua as "add the default search path here" (which does
> indeed contain ?.lua, but also contains more).

Testing done:

- Build with `nix-build -I /path/to/repo -A awesome`
- Start an X session with xterm only
- Start xephyr, e.g. `Xephyr :1 -name xephyr -screen 512x384 -ac -br -noreset &`
- Run awesome like `DISPLAY=:1.0 ./result/bin/awesome`. Additionally, add
  `--search` options to expose lua modules that have a name clash with lgi's
  internal ones (see #60232 for more details) and `require` them in `rc.lua` to
  prove that they are loaded correctly
2019-04-27 15:49:43 +01:00

73 lines
2.4 KiB
Nix

{ stdenv, fetchFromGitHub, luaPackages, cairo, librsvg, cmake, imagemagick, pkgconfig, gdk_pixbuf
, xorg, libstartup_notification, libxdg_basedir, libpthreadstubs
, xcb-util-cursor, makeWrapper, pango, gobject-introspection
, which, dbus, nettools, git, doxygen
, xmlto, docbook_xml_dtd_45, docbook_xsl, findXMLCatalogs
, libxkbcommon, xcbutilxrm, hicolor-icon-theme
, asciidoctor
}:
with luaPackages; stdenv.mkDerivation rec {
name = "awesome-${version}";
version = "4.3";
src = fetchFromGitHub {
owner = "awesomewm";
repo = "awesome";
rev = "v${version}";
sha256 = "1i7ajmgbsax4lzpgnmkyv35x8vxqi0j84a14k6zys4blx94m9yjf";
};
nativeBuildInputs = [
cmake
doxygen
imagemagick
makeWrapper
pkgconfig
xmlto docbook_xml_dtd_45
docbook_xsl findXMLCatalogs
asciidoctor
];
propagatedUserEnvPkgs = [ hicolor-icon-theme ];
buildInputs = [ cairo librsvg dbus gdk_pixbuf gobject-introspection
git lgi libpthreadstubs libstartup_notification
libxdg_basedir lua nettools pango xcb-util-cursor
xorg.libXau xorg.libXdmcp xorg.libxcb xorg.libxshmfence
xorg.xcbutil xorg.xcbutilimage xorg.xcbutilkeysyms
xorg.xcbutilrenderutil xorg.xcbutilwm libxkbcommon
xcbutilxrm ];
#cmakeFlags = "-DGENERATE_MANPAGES=ON";
cmakeFlags = "-DOVERRIDE_VERSION=${version}";
GI_TYPELIB_PATH = "${pango.out}/lib/girepository-1.0";
# LUA_CPATH and LUA_PATH are used only for *building*, see the --search flags
# below for how awesome finds the libraries it needs at runtime.
LUA_CPATH = "${lgi}/lib/lua/${lua.luaversion}/?.so";
LUA_PATH = "${lgi}/share/lua/${lua.luaversion}/?.lua;;";
postInstall = ''
wrapProgram $out/bin/awesome \
--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
--add-flags '--search ${lgi}/lib/lua/${lua.luaversion}' \
--add-flags '--search ${lgi}/share/lua/${lua.luaversion}' \
--prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH"
wrapProgram $out/bin/awesome-client \
--prefix PATH : "${which}/bin"
'';
passthru = {
inherit lua;
};
meta = with stdenv.lib; {
description = "Highly configurable, dynamic window manager for X";
homepage = https://awesomewm.org/;
license = licenses.gpl2Plus;
maintainers = with maintainers; [ lovek323 rasendubi ndowens ];
platforms = platforms.linux;
};
}