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;
|
|
|
|
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
|
2017-10-17 15:09:42 +01:00
|
|
|
{
|
2017-10-25 17:35:00 +01:00
|
|
|
options.programs.sway = {
|
|
|
|
enable = mkEnableOption "sway";
|
|
|
|
|
|
|
|
extraSessionCommands = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
|
|
|
example = ''
|
2017-10-25 20:29:27 +01:00
|
|
|
export XKB_DEFAULT_LAYOUT=us,de
|
|
|
|
export XKB_DEFAULT_VARIANT=,nodeadkeys
|
2017-10-25 17:35:00 +01:00
|
|
|
export XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Shell commands executed just before sway is started.
|
|
|
|
'';
|
|
|
|
};
|
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-10-25 17:35:00 +01:00
|
|
|
example = literalExample ''
|
|
|
|
with pkgs; [
|
2017-10-25 20:29:27 +01:00
|
|
|
i3status xwayland rxvt_unicode dmenu
|
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-10-25 17:35:00 +01:00
|
|
|
source = "${swayJoined}/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 = {};
|
2017-10-25 17:35:00 +01:00
|
|
|
|
|
|
|
hardware.opengl.enable = mkDefault true;
|
|
|
|
fonts.enableDefaultFonts = mkDefault true;
|
2017-10-17 15:09:42 +01:00
|
|
|
};
|
|
|
|
}
|