2017-10-17 15:09:42 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2017-10-25 17:35:00 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.sway;
|
2017-12-23 20:03:06 +00:00
|
|
|
swayPackage = pkgs.sway;
|
2017-10-25 17:35:00 +01:00
|
|
|
|
2017-12-21 16:16:19 +00:00
|
|
|
swayWrapped = pkgs.writeShellScriptBin "sway" ''
|
2019-01-01 07:45:26 +00: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 20:03:06 +00:00
|
|
|
exec sway-setcap "$@"
|
|
|
|
else
|
2019-01-01 07:45:26 +00:00
|
|
|
exec ${pkgs.dbus}/bin/dbus-run-session sway-setcap "$@"
|
2017-11-07 17:31:49 +00:00
|
|
|
fi
|
2017-10-25 17:35:00 +01:00
|
|
|
'';
|
|
|
|
swayJoined = pkgs.symlinkJoin {
|
2017-12-23 20:03:06 +00:00
|
|
|
name = "sway-joined";
|
|
|
|
paths = [ swayWrapped swayPackage ];
|
2017-10-25 17:35:00 +01:00
|
|
|
};
|
2017-12-23 20:03:06 +00:00
|
|
|
in {
|
2017-10-25 17:35:00 +01:00
|
|
|
options.programs.sway = {
|
2017-12-23 20:03:06 +00: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 17:35:00 +01:00
|
|
|
|
|
|
|
extraSessionCommands = mkOption {
|
2017-12-23 20:03:06 +00:00
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2017-10-25 17:35:00 +01:00
|
|
|
example = ''
|
2017-12-23 20:03:06 +00: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 17:35:00 +01:00
|
|
|
'';
|
|
|
|
description = ''
|
2017-12-23 20:03:06 +00:00
|
|
|
Shell commands executed just before Sway is started.
|
2017-10-25 17:35:00 +01:00
|
|
|
'';
|
|
|
|
};
|
2017-10-17 15:09:42 +01:00
|
|
|
|
2017-10-25 17:35:00 +01:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
2017-10-25 20:29:27 +01:00
|
|
|
default = with pkgs; [
|
|
|
|
i3status xwayland rxvt_unicode dmenu
|
|
|
|
];
|
2017-12-23 20:03:06 +00:00
|
|
|
defaultText = literalExample ''
|
|
|
|
with pkgs; [ i3status xwayland rxvt_unicode dmenu ];
|
|
|
|
'';
|
2017-10-25 17:35:00 +01:00
|
|
|
example = literalExample ''
|
|
|
|
with pkgs; [
|
2017-12-23 20:03:06 +00:00
|
|
|
i3lock light termite
|
2017-10-25 17:35:00 +01:00
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages to be installed system wide.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ swayJoined ] ++ cfg.extraPackages;
|
2017-10-17 15:09:42 +01:00
|
|
|
security.wrappers.sway = {
|
2017-11-03 18:00:46 +00:00
|
|
|
program = "sway-setcap";
|
2017-12-23 20:03:06 +00:00
|
|
|
source = "${swayPackage}/bin/sway";
|
2017-10-17 15:09:42 +01:00
|
|
|
capabilities = "cap_sys_ptrace,cap_sys_tty_config=eip";
|
|
|
|
owner = "root";
|
|
|
|
group = "sway";
|
|
|
|
permissions = "u+rx,g+rx";
|
|
|
|
};
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups.sway = {};
|
2017-12-21 16:16:19 +00:00
|
|
|
security.pam.services.swaylock = {};
|
2017-10-25 17:35:00 +01:00
|
|
|
|
|
|
|
hardware.opengl.enable = mkDefault true;
|
|
|
|
fonts.enableDefaultFonts = mkDefault true;
|
2017-12-21 16:16:19 +00:00
|
|
|
programs.dconf.enable = mkDefault true;
|
2017-10-17 15:09:42 +01:00
|
|
|
};
|
2017-12-23 20:03:06 +00:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ gnidorah primeos ];
|
2017-10-17 15:09:42 +01:00
|
|
|
}
|