2017-10-17 15:09:42 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2017-10-25 17:35:00 +01:00
|
|
|
|
|
|
|
let
|
2019-03-11 16:32:38 +00:00
|
|
|
cfg = config.programs.sway;
|
|
|
|
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
|
2019-03-11 16:18:19 +00:00
|
|
|
exec ${swayPackage}/bin/sway "$@"
|
2017-12-23 20:03:06 +00:00
|
|
|
else
|
2019-03-11 16:18:19 +00:00
|
|
|
exec ${pkgs.dbus}/bin/dbus-run-session ${swayPackage}/bin/sway "$@"
|
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 {
|
2019-03-11 16:32:38 +00:00
|
|
|
options.programs.sway = {
|
2017-12-23 20:03:06 +00:00
|
|
|
enable = mkEnableOption ''
|
2019-03-11 16:32:38 +00:00
|
|
|
Sway, the i3-compatible tiling Wayland compositor. You can manually launch
|
|
|
|
Sway by executing "exec sway" on a TTY. Copy /etc/sway/config to
|
|
|
|
~/.config/sway/config to modify the default configuration. See
|
|
|
|
https://github.com/swaywm/sway/wiki and "man 5 sway" for more information.
|
|
|
|
Please have a look at the "extraSessionCommands" example for running
|
|
|
|
programs natively under Wayland'';
|
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 = ''
|
2019-03-11 16:18:19 +00:00
|
|
|
export SDL_VIDEODRIVER=wayland
|
|
|
|
# needs qt5.qtwayland in systemPackages
|
|
|
|
export QT_QPA_PLATFORM=wayland
|
|
|
|
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
|
|
|
|
# Fix for some Java AWT applications (e.g. Android Studio),
|
|
|
|
# use this if they aren't displayed properly:
|
|
|
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
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; [
|
2019-03-11 16:18:19 +00:00
|
|
|
swaylock swayidle
|
|
|
|
xwayland rxvt_unicode dmenu
|
2017-10-25 20:29:27 +01:00
|
|
|
];
|
2017-12-23 20:03:06 +00:00
|
|
|
defaultText = literalExample ''
|
2019-03-11 16:18:19 +00:00
|
|
|
with pkgs; [ swaylock swayidle xwayland rxvt_unicode dmenu ];
|
2017-12-23 20:03:06 +00:00
|
|
|
'';
|
2017-10-25 17:35:00 +01:00
|
|
|
example = literalExample ''
|
|
|
|
with pkgs; [
|
2019-03-11 16:18:19 +00:00
|
|
|
xwayland
|
|
|
|
i3status i3status-rust
|
|
|
|
termite rofi light
|
2017-10-25 17:35:00 +01:00
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages to be installed system wide.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-03-11 16:32:38 +00:00
|
|
|
environment = {
|
|
|
|
systemPackages = [ swayJoined ] ++ cfg.extraPackages;
|
|
|
|
etc = {
|
2019-04-27 21:38:18 +01:00
|
|
|
"sway/config".source = mkOptionDefault "${swayPackage}/etc/sway/config";
|
|
|
|
#"sway/security.d".source = mkOptionDefault "${swayPackage}/etc/sway/security.d/";
|
|
|
|
#"sway/config.d".source = mkOptionDefault "${swayPackage}/etc/sway/config.d/";
|
2019-03-11 16:32:38 +00:00
|
|
|
};
|
|
|
|
};
|
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
|
|
|
|
2019-03-11 16:18:19 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ gnidorah primeos colemickens ];
|
2017-10-17 15:09:42 +01:00
|
|
|
}
|