2017-10-17 16:09:42 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2017-10-25 18:35:00 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.sway;
|
2017-12-23 21:03:06 +01:00
|
|
|
swayPackage = pkgs.sway;
|
2017-10-25 18:35:00 +02:00
|
|
|
|
2017-12-21 17:16:19 +01:00
|
|
|
swayWrapped = pkgs.writeShellScriptBin "sway" ''
|
2019-01-01 08:45:26 +01:00
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
|
|
|
|
export _SWAY_WRAPPER_ALREADY_EXECUTED=1
|
|
|
|
${cfg.extraSessionCommands}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
|
|
|
|
export DBUS_SESSION_BUS_ADDRESS
|
2017-12-23 21:03:06 +01:00
|
|
|
exec sway-setcap "$@"
|
|
|
|
else
|
2019-01-01 08:45:26 +01:00
|
|
|
exec ${pkgs.dbus}/bin/dbus-run-session sway-setcap "$@"
|
2017-11-07 18:31:49 +01:00
|
|
|
fi
|
2017-10-25 18:35:00 +02:00
|
|
|
'';
|
|
|
|
swayJoined = pkgs.symlinkJoin {
|
2017-12-23 21:03:06 +01:00
|
|
|
name = "sway-joined";
|
|
|
|
paths = [ swayWrapped swayPackage ];
|
2017-10-25 18:35:00 +02:00
|
|
|
};
|
2017-12-23 21:03:06 +01:00
|
|
|
in {
|
2017-10-25 18:35:00 +02:00
|
|
|
options.programs.sway = {
|
2017-12-23 21:03:06 +01:00
|
|
|
enable = mkEnableOption ''
|
|
|
|
the tiling Wayland compositor Sway. After adding yourself to the "sway"
|
|
|
|
group you can manually launch Sway by executing "sway" from a terminal.
|
|
|
|
If you call "sway" with any parameters the extraSessionCommands won't be
|
|
|
|
executed and Sway won't be launched with dbus-launch'';
|
2017-10-25 18:35:00 +02:00
|
|
|
|
|
|
|
extraSessionCommands = mkOption {
|
2017-12-23 21:03:06 +01:00
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2017-10-25 18:35:00 +02:00
|
|
|
example = ''
|
2017-12-23 21:03:06 +01:00
|
|
|
# Define a keymap (US QWERTY is the default)
|
|
|
|
export XKB_DEFAULT_LAYOUT=de,us
|
|
|
|
export XKB_DEFAULT_VARIANT=nodeadkeys
|
|
|
|
export XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,caps:escape
|
|
|
|
# Change the Keyboard repeat delay and rate
|
|
|
|
export WLC_REPEAT_DELAY=660
|
|
|
|
export WLC_REPEAT_RATE=25
|
2017-10-25 18:35:00 +02:00
|
|
|
'';
|
|
|
|
description = ''
|
2017-12-23 21:03:06 +01:00
|
|
|
Shell commands executed just before Sway is started.
|
2017-10-25 18:35:00 +02:00
|
|
|
'';
|
|
|
|
};
|
2017-10-17 16:09:42 +02:00
|
|
|
|
2017-10-25 18:35:00 +02:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
2017-10-25 21:29:27 +02:00
|
|
|
default = with pkgs; [
|
|
|
|
i3status xwayland rxvt_unicode dmenu
|
|
|
|
];
|
2017-12-23 21:03:06 +01:00
|
|
|
defaultText = literalExample ''
|
|
|
|
with pkgs; [ i3status xwayland rxvt_unicode dmenu ];
|
|
|
|
'';
|
2017-10-25 18:35:00 +02:00
|
|
|
example = literalExample ''
|
|
|
|
with pkgs; [
|
2017-12-23 21:03:06 +01:00
|
|
|
i3lock light termite
|
2017-10-25 18:35:00 +02:00
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages to be installed system wide.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ swayJoined ] ++ cfg.extraPackages;
|
2017-10-17 16:09:42 +02:00
|
|
|
security.wrappers.sway = {
|
2017-11-03 19:00:46 +01:00
|
|
|
program = "sway-setcap";
|
2017-12-23 21:03:06 +01:00
|
|
|
source = "${swayPackage}/bin/sway";
|
2017-10-17 16:09:42 +02:00
|
|
|
capabilities = "cap_sys_ptrace,cap_sys_tty_config=eip";
|
|
|
|
owner = "root";
|
|
|
|
group = "sway";
|
|
|
|
permissions = "u+rx,g+rx";
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.sway = {};
|
2017-12-21 17:16:19 +01:00
|
|
|
security.pam.services.swaylock = {};
|
2017-10-25 18:35:00 +02:00
|
|
|
|
|
|
|
hardware.opengl.enable = mkDefault true;
|
|
|
|
fonts.enableDefaultFonts = mkDefault true;
|
2017-12-21 17:16:19 +01:00
|
|
|
programs.dconf.enable = mkDefault true;
|
2017-10-17 16:09:42 +02:00
|
|
|
};
|
2017-12-23 21:03:06 +01:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ gnidorah primeos ];
|
2017-10-17 16:09:42 +02:00
|
|
|
}
|