2017-10-17 14:09:42 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2017-10-25 16:35:00 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.sway;
|
2017-12-23 20:03:06 +00:00
|
|
|
swayPackage = pkgs.sway;
|
2017-10-25 16:35:00 +00:00
|
|
|
|
2017-12-21 16:16:19 +00:00
|
|
|
swayWrapped = pkgs.writeShellScriptBin "sway" ''
|
2017-12-23 20:03:06 +00:00
|
|
|
if [[ "$#" -ge 1 ]]; then
|
|
|
|
exec sway-setcap "$@"
|
|
|
|
else
|
|
|
|
${cfg.extraSessionCommands}
|
|
|
|
exec ${pkgs.dbus.dbus-launch} --exit-with-session sway-setcap
|
2017-11-07 17:31:49 +00:00
|
|
|
fi
|
2017-10-25 16:35:00 +00:00
|
|
|
'';
|
|
|
|
swayJoined = pkgs.symlinkJoin {
|
2017-12-23 20:03:06 +00:00
|
|
|
name = "sway-joined";
|
|
|
|
paths = [ swayWrapped swayPackage ];
|
2017-10-25 16:35:00 +00:00
|
|
|
};
|
2017-12-23 20:03:06 +00:00
|
|
|
in {
|
2017-10-25 16:35:00 +00: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 16:35:00 +00:00
|
|
|
|
|
|
|
extraSessionCommands = mkOption {
|
2017-12-23 20:03:06 +00:00
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2017-10-25 16:35:00 +00: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 16:35:00 +00:00
|
|
|
'';
|
|
|
|
description = ''
|
2017-12-23 20:03:06 +00:00
|
|
|
Shell commands executed just before Sway is started.
|
2017-10-25 16:35:00 +00:00
|
|
|
'';
|
|
|
|
};
|
2017-10-17 14:09:42 +00:00
|
|
|
|
2017-10-25 16:35:00 +00:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
2017-10-25 19:29:27 +00: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 16:35:00 +00:00
|
|
|
example = literalExample ''
|
|
|
|
with pkgs; [
|
2017-12-23 20:03:06 +00:00
|
|
|
i3lock light termite
|
2017-10-25 16:35:00 +00:00
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages to be installed system wide.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ swayJoined ] ++ cfg.extraPackages;
|
2017-10-17 14:09:42 +00: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 14:09:42 +00:00
|
|
|
capabilities = "cap_sys_ptrace,cap_sys_tty_config=eip";
|
|
|
|
owner = "root";
|
|
|
|
group = "sway";
|
|
|
|
permissions = "u+rx,g+rx";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraGroups.sway = {};
|
2017-12-21 16:16:19 +00:00
|
|
|
security.pam.services.swaylock = {};
|
2017-10-25 16:35:00 +00: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 14:09:42 +00:00
|
|
|
};
|
2017-12-23 20:03:06 +00:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ gnidorah primeos ];
|
2017-10-17 14:09:42 +00:00
|
|
|
}
|