nixpkgs/nixos/modules/programs/sway.nix

86 lines
2.4 KiB
Nix
Raw Normal View History

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;
swayPackage = pkgs.sway;
2017-10-25 17:35:00 +01:00
swayWrapped = pkgs.writeShellScriptBin "sway" ''
if [[ "$#" -ge 1 ]]; then
exec sway-setcap "$@"
else
${cfg.extraSessionCommands}
exec ${pkgs.dbus.dbus-launch} --exit-with-session sway-setcap
fi
2017-10-25 17:35:00 +01:00
'';
swayJoined = pkgs.symlinkJoin {
name = "sway-joined";
paths = [ swayWrapped swayPackage ];
2017-10-25 17:35:00 +01:00
};
in {
2017-10-25 17:35:00 +01:00
options.programs.sway = {
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 {
type = types.lines;
default = "";
2017-10-25 17:35:00 +01:00
example = ''
# 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 = ''
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
];
defaultText = literalExample ''
with pkgs; [ i3status xwayland rxvt_unicode dmenu ];
'';
2017-10-25 17:35:00 +01:00
example = literalExample ''
with pkgs; [
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 = {
program = "sway-setcap";
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";
};
users.extraGroups.sway = {};
security.pam.services.swaylock = {};
2017-10-25 17:35:00 +01:00
hardware.opengl.enable = mkDefault true;
fonts.enableDefaultFonts = mkDefault true;
programs.dconf.enable = mkDefault true;
2017-10-17 15:09:42 +01:00
};
meta.maintainers = with lib.maintainers; [ gnidorah primeos ];
2017-10-17 15:09:42 +01:00
}