Merge pull request #30800 from gnidorah/sway

sway module: make it useful to end user
This commit is contained in:
Jörg Thalheim 2017-10-25 20:20:50 +01:00 committed by GitHub
commit cb217f87a0
3 changed files with 84 additions and 32 deletions

@ -1,13 +1,61 @@
{ config, pkgs, lib, ... }:
with lib;
{
options.programs.sway.enable = mkEnableOption "sway";
config = mkIf config.programs.sway.enable {
environment.systemPackages = [ pkgs.sway pkgs.xwayland ];
let
cfg = config.programs.sway;
sway = pkgs.sway;
swayWrapped = pkgs.writeScriptBin "sway" ''
#! ${pkgs.stdenv.shell}
${cfg.extraSessionCommands}
PATH="${sway}/bin:$PATH"
exec ${pkgs.dbus.dbus-launch} --exit-with-session "${sway}/bin/sway"
'';
swayJoined = pkgs.symlinkJoin {
name = "sway-wrapped";
paths = [ swayWrapped sway ];
};
in
{
options.programs.sway = {
enable = mkEnableOption "sway";
extraSessionCommands = mkOption {
default = "";
type = types.lines;
example = ''
export XKB_DEFAULT_LAYOUT=us,ru
export XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
'';
description = ''
Shell commands executed just before sway is started.
'';
};
extraPackages = mkOption {
type = with types; listOf package;
default = with pkgs; [ ];
example = literalExample ''
with pkgs; [
i3status
xwayland j4-dmenu-desktop dunst
qt5.qtwayland
imagemagick
]
'';
description = ''
Extra packages to be installed system wide.
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ swayJoined ] ++ cfg.extraPackages;
security.wrappers.sway = {
source = "${pkgs.sway}/bin/sway";
source = "${swayJoined}/bin/sway";
capabilities = "cap_sys_ptrace,cap_sys_tty_config=eip";
owner = "root";
group = "sway";
@ -15,5 +63,8 @@ with lib;
};
users.extraGroups.sway = {};
hardware.opengl.enable = mkDefault true;
fonts.enableDefaultFonts = mkDefault true;
};
}

@ -1,8 +1,9 @@
{ stdenv, fetchFromGitHub
, makeWrapper, cmake, pkgconfig, asciidoc, libxslt, docbook_xsl
, wayland, wlc, libxkbcommon, pixman, fontconfig, pcre, json_c, dbus_libs
, pango, cairo, libinput, libcap, xwayland, pam, gdk_pixbuf, libpthreadstubs
, cmake, pkgconfig, asciidoc, libxslt, docbook_xsl
, wayland, wlc, libxkbcommon, pcre, json_c, dbus_libs
, pango, cairo, libinput, libcap, pam, gdk_pixbuf, libpthreadstubs
, libXdmcp
, buildDocs ? true
}:
stdenv.mkDerivation rec {
@ -17,28 +18,17 @@ stdenv.mkDerivation rec {
};
nativeBuildInputs = [
makeWrapper cmake pkgconfig
asciidoc libxslt docbook_xsl
];
cmake pkgconfig
] ++ stdenv.lib.optional buildDocs [ asciidoc libxslt docbook_xsl ];
buildInputs = [
wayland wlc libxkbcommon pixman fontconfig pcre json_c dbus_libs
pango cairo libinput libcap xwayland pam gdk_pixbuf libpthreadstubs
wayland wlc libxkbcommon pcre json_c dbus_libs
pango cairo libinput libcap pam gdk_pixbuf libpthreadstubs
libXdmcp
];
patchPhase = ''
sed -i s@/etc/sway@$out/etc/sway@g CMakeLists.txt;
'';
enableParallelBuilding = true;
makeFlags = "PREFIX=$(out)";
cmakeFlags = "-DVERSION=${version}";
installPhase = "PREFIX=$out make install";
LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath [ wlc dbus_libs ];
preFixup = ''
wrapProgram $out/bin/sway \
--prefix LD_LIBRARY_PATH : "${LD_LIBRARY_PATH}";
'';
meta = with stdenv.lib; {
description = "i3-compatible window manager for Wayland";

@ -1,11 +1,17 @@
{ stdenv, fetchFromGitHub, cmake, pkgconfig
, wayland, pixman, libxkbcommon, libinput, libxcb, xcbutilwm, xcbutilimage, mesa
, libdrm, udev, libX11, libXdamage, systemd, dbus_libs, wayland-protocols
, libpthreadstubs, libXau, libXdmcp, libXext, libXxf86vm
{ stdenv, fetchFromGitHub, fetchpatch, cmake, pkgconfig
, wayland, pixman, libxkbcommon, libinput, xcbutilwm, xcbutilimage, mesa_noglu
, libX11, dbus_libs, wayland-protocols
, libpthreadstubs, libXdmcp, libXext
, withOptionalPackages ? true, zlib, valgrind, doxygen
}:
stdenv.mkDerivation rec {
let
# for 0.0.10
xwaylandPatch = fetchpatch {
url = "https://github.com/Cloudef/wlc/commit/a130f6006560fb8ac02fb59a90ced1659563f9ca.diff";
sha256 = "0kzcbqklcyg8bganm65di8cif6dpc8bkrsvkjia09kr92lymxm2c";
};
in stdenv.mkDerivation rec {
name = "wlc-${version}";
version = "0.0.10";
@ -17,16 +23,21 @@ stdenv.mkDerivation rec {
sha256 = "09kvwhrpgkxlagn9lgqxc80jbg56djn29a6z0n6h0dsm90ysyb2k";
};
patches = [
xwaylandPatch
];
nativeBuildInputs = [ cmake pkgconfig ];
buildInputs = [
wayland pixman libxkbcommon libinput libxcb xcbutilwm xcbutilimage mesa
libdrm udev libX11 libXdamage systemd dbus_libs wayland-protocols
libpthreadstubs libXau libXdmcp libXext libXxf86vm ]
wayland pixman libxkbcommon libinput xcbutilwm xcbutilimage mesa_noglu
libX11 dbus_libs wayland-protocols
libpthreadstubs libXdmcp libXext ]
++ stdenv.lib.optionals withOptionalPackages [ zlib valgrind doxygen ];
doCheck = true;
checkTarget = "test";
enableParallelBuilding = true;
meta = with stdenv.lib; {
description = "A library for making a simple Wayland compositor";