2019-09-04 04:30:44 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.wayland.windowManager.sway;
|
|
|
|
|
|
|
|
commonOptions = import ./lib/options.nix {
|
2020-07-13 13:31:55 +02:00
|
|
|
inherit config lib cfg pkgs;
|
2019-09-04 04:30:44 +02:00
|
|
|
moduleName = "sway";
|
|
|
|
capitalModuleName = "Sway";
|
|
|
|
};
|
|
|
|
|
|
|
|
configModule = types.submodule {
|
|
|
|
options = {
|
|
|
|
inherit (commonOptions)
|
|
|
|
fonts window floating focus assigns workspaceLayout
|
|
|
|
workspaceAutoBackAndForth modifier keycodebindings colors bars startup
|
2021-06-03 02:03:20 +02:00
|
|
|
gaps menu terminal defaultWorkspace workspaceOutputAssign;
|
2019-09-04 04:30:44 +02:00
|
|
|
|
|
|
|
left = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "h";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Home row direction key for moving left.";
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
down = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "j";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Home row direction key for moving down.";
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
up = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "k";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Home row direction key for moving up.";
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
right = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "l";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Home row direction key for moving right.";
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
keybindings = mkOption {
|
|
|
|
type = types.attrsOf (types.nullOr types.str);
|
|
|
|
default = mapAttrs (n: mkOptionDefault) {
|
|
|
|
"${cfg.config.modifier}+Return" = "exec ${cfg.config.terminal}";
|
|
|
|
"${cfg.config.modifier}+Shift+q" = "kill";
|
|
|
|
"${cfg.config.modifier}+d" = "exec ${cfg.config.menu}";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+${cfg.config.left}" = "focus left";
|
|
|
|
"${cfg.config.modifier}+${cfg.config.down}" = "focus down";
|
|
|
|
"${cfg.config.modifier}+${cfg.config.up}" = "focus up";
|
|
|
|
"${cfg.config.modifier}+${cfg.config.right}" = "focus right";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+Left" = "focus left";
|
|
|
|
"${cfg.config.modifier}+Down" = "focus down";
|
|
|
|
"${cfg.config.modifier}+Up" = "focus up";
|
|
|
|
"${cfg.config.modifier}+Right" = "focus right";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+Shift+${cfg.config.left}" = "move left";
|
|
|
|
"${cfg.config.modifier}+Shift+${cfg.config.down}" = "move down";
|
|
|
|
"${cfg.config.modifier}+Shift+${cfg.config.up}" = "move up";
|
|
|
|
"${cfg.config.modifier}+Shift+${cfg.config.right}" = "move right";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+Shift+Left" = "move left";
|
|
|
|
"${cfg.config.modifier}+Shift+Down" = "move down";
|
|
|
|
"${cfg.config.modifier}+Shift+Up" = "move up";
|
|
|
|
"${cfg.config.modifier}+Shift+Right" = "move right";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+b" = "splith";
|
|
|
|
"${cfg.config.modifier}+v" = "splitv";
|
|
|
|
"${cfg.config.modifier}+f" = "fullscreen toggle";
|
|
|
|
"${cfg.config.modifier}+a" = "focus parent";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+s" = "layout stacking";
|
|
|
|
"${cfg.config.modifier}+w" = "layout tabbed";
|
|
|
|
"${cfg.config.modifier}+e" = "layout toggle split";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+Shift+space" = "floating toggle";
|
|
|
|
"${cfg.config.modifier}+space" = "focus mode_toggle";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+1" = "workspace number 1";
|
|
|
|
"${cfg.config.modifier}+2" = "workspace number 2";
|
|
|
|
"${cfg.config.modifier}+3" = "workspace number 3";
|
|
|
|
"${cfg.config.modifier}+4" = "workspace number 4";
|
|
|
|
"${cfg.config.modifier}+5" = "workspace number 5";
|
|
|
|
"${cfg.config.modifier}+6" = "workspace number 6";
|
|
|
|
"${cfg.config.modifier}+7" = "workspace number 7";
|
|
|
|
"${cfg.config.modifier}+8" = "workspace number 8";
|
|
|
|
"${cfg.config.modifier}+9" = "workspace number 9";
|
2024-02-10 19:59:52 +01:00
|
|
|
"${cfg.config.modifier}+0" = "workspace number 10";
|
2019-09-04 04:30:44 +02:00
|
|
|
|
|
|
|
"${cfg.config.modifier}+Shift+1" =
|
|
|
|
"move container to workspace number 1";
|
|
|
|
"${cfg.config.modifier}+Shift+2" =
|
|
|
|
"move container to workspace number 2";
|
|
|
|
"${cfg.config.modifier}+Shift+3" =
|
|
|
|
"move container to workspace number 3";
|
|
|
|
"${cfg.config.modifier}+Shift+4" =
|
|
|
|
"move container to workspace number 4";
|
|
|
|
"${cfg.config.modifier}+Shift+5" =
|
|
|
|
"move container to workspace number 5";
|
|
|
|
"${cfg.config.modifier}+Shift+6" =
|
|
|
|
"move container to workspace number 6";
|
|
|
|
"${cfg.config.modifier}+Shift+7" =
|
|
|
|
"move container to workspace number 7";
|
|
|
|
"${cfg.config.modifier}+Shift+8" =
|
|
|
|
"move container to workspace number 8";
|
|
|
|
"${cfg.config.modifier}+Shift+9" =
|
|
|
|
"move container to workspace number 9";
|
2024-02-10 19:59:52 +01:00
|
|
|
"${cfg.config.modifier}+Shift+0" =
|
|
|
|
"move container to workspace number 10";
|
2019-09-04 04:30:44 +02:00
|
|
|
|
|
|
|
"${cfg.config.modifier}+Shift+minus" = "move scratchpad";
|
|
|
|
"${cfg.config.modifier}+minus" = "scratchpad show";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+Shift+c" = "reload";
|
|
|
|
"${cfg.config.modifier}+Shift+e" =
|
|
|
|
"exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'";
|
|
|
|
|
|
|
|
"${cfg.config.modifier}+r" = "mode resize";
|
|
|
|
};
|
|
|
|
defaultText = "Default sway keybindings.";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-09-04 04:30:44 +02:00
|
|
|
An attribute set that assigns a key press to an action using a key symbol.
|
2023-07-01 01:30:13 +02:00
|
|
|
See <https://i3wm.org/docs/userguide.html#keybindings>.
|
|
|
|
|
|
|
|
Consider to use `lib.mkOptionDefault` function to extend or override
|
2019-09-04 04:30:44 +02:00
|
|
|
default keybindings instead of specifying all of them from scratch.
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2019-09-04 04:30:44 +02:00
|
|
|
let
|
2020-05-24 13:00:51 +02:00
|
|
|
modifier = config.wayland.windowManager.sway.config.modifier;
|
|
|
|
in lib.mkOptionDefault {
|
2019-09-04 04:30:44 +02:00
|
|
|
"''${modifier}+Return" = "exec ${cfg.config.terminal}";
|
|
|
|
"''${modifier}+Shift+q" = "kill";
|
|
|
|
"''${modifier}+d" = "exec ${cfg.config.menu}";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-05-30 13:58:05 +02:00
|
|
|
bindkeysToCode = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
example = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Whether to make use of {option}`--to-code` in keybindings.
|
2020-05-30 13:58:05 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-09-04 04:30:44 +02:00
|
|
|
input = mkOption {
|
|
|
|
type = types.attrsOf (types.attrsOf types.str);
|
|
|
|
default = { };
|
|
|
|
example = { "*" = { xkb_variant = "dvorak"; }; };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-04-09 20:01:34 +02:00
|
|
|
An attribute set that defines input modules. See
|
2023-07-01 01:30:13 +02:00
|
|
|
{manpage}`sway-input(5)`
|
2021-04-09 20:01:34 +02:00
|
|
|
for options.
|
2019-09-04 04:30:44 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
output = mkOption {
|
|
|
|
type = types.attrsOf (types.attrsOf types.str);
|
|
|
|
default = { };
|
2020-07-14 10:17:05 +02:00
|
|
|
example = { "HDMI-A-2" = { bg = "~/path/to/background.png fill"; }; };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-04-09 20:01:34 +02:00
|
|
|
An attribute set that defines output modules. See
|
2023-07-01 01:30:13 +02:00
|
|
|
{manpage}`sway-output(5)`
|
2021-04-09 20:01:34 +02:00
|
|
|
for options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
seat = mkOption {
|
|
|
|
type = types.attrsOf (types.attrsOf types.str);
|
|
|
|
default = { };
|
|
|
|
example = { "*" = { hide_cursor = "when-typing enable"; }; };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-04-09 20:01:34 +02:00
|
|
|
An attribute set that defines seat modules. See
|
2023-07-01 01:30:13 +02:00
|
|
|
{manpage}`sway-input(5)`
|
2021-04-09 20:01:34 +02:00
|
|
|
for options.
|
2019-09-04 04:30:44 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
modes = mkOption {
|
|
|
|
type = types.attrsOf (types.attrsOf types.str);
|
|
|
|
default = {
|
|
|
|
resize = {
|
|
|
|
"${cfg.config.left}" = "resize shrink width 10 px";
|
|
|
|
"${cfg.config.down}" = "resize grow height 10 px";
|
|
|
|
"${cfg.config.up}" = "resize shrink height 10 px";
|
|
|
|
"${cfg.config.right}" = "resize grow width 10 px";
|
|
|
|
"Left" = "resize shrink width 10 px";
|
|
|
|
"Down" = "resize grow height 10 px";
|
|
|
|
"Up" = "resize shrink height 10 px";
|
|
|
|
"Right" = "resize grow width 10 px";
|
|
|
|
"Escape" = "mode default";
|
|
|
|
"Return" = "mode default";
|
|
|
|
};
|
|
|
|
};
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-09-04 04:30:44 +02:00
|
|
|
An attribute set that defines binding modes and keybindings
|
|
|
|
inside them
|
|
|
|
|
|
|
|
Only basic keybinding is supported (bindsym keycomb action),
|
|
|
|
for more advanced setup use 'sway.extraConfig'.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
wrapperOptions = types.submodule {
|
|
|
|
options = let
|
|
|
|
mkWrapperFeature = default: description:
|
|
|
|
mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
inherit default;
|
|
|
|
example = !default;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Whether to make use of the ${description}";
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
base = mkWrapperFeature true ''
|
|
|
|
base wrapper to execute extra session commands and prepend a
|
|
|
|
dbus-run-session to the sway command.
|
|
|
|
'';
|
|
|
|
gtk = mkWrapperFeature false ''
|
|
|
|
wrapGAppsHook wrapper to execute sway with required environment
|
|
|
|
variables for GTK applications.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
commonFunctions = import ./lib/functions.nix {
|
2022-03-21 23:52:57 +01:00
|
|
|
inherit config cfg lib;
|
2019-09-04 04:30:44 +02:00
|
|
|
moduleName = "sway";
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit (commonFunctions)
|
|
|
|
keybindingsStr keycodebindingsStr modeStr assignStr barStr gapsStr
|
2021-05-04 05:54:35 +02:00
|
|
|
floatingCriteriaStr windowCommandsStr colorSetStr windowBorderString
|
2021-06-03 02:03:20 +02:00
|
|
|
fontConfigStr keybindingDefaultWorkspace keybindingsRest workspaceOutputStr;
|
2019-09-04 04:30:44 +02:00
|
|
|
|
|
|
|
startupEntryStr = { command, always, ... }: ''
|
|
|
|
${if always then "exec_always" else "exec"} ${command}
|
|
|
|
'';
|
|
|
|
|
2021-04-09 20:01:34 +02:00
|
|
|
moduleStr = moduleType: name: attrs: ''
|
|
|
|
${moduleType} "${name}" {
|
2019-09-04 04:30:44 +02:00
|
|
|
${concatStringsSep "\n"
|
2024-09-06 14:51:44 +02:00
|
|
|
(mapAttrsToList (name: value: " ${name} ${value}") attrs)}
|
2019-09-04 04:30:44 +02:00
|
|
|
}
|
|
|
|
'';
|
2021-04-09 20:01:34 +02:00
|
|
|
inputStr = moduleStr "input";
|
|
|
|
outputStr = moduleStr "output";
|
|
|
|
seatStr = moduleStr "seat";
|
2019-09-04 04:30:44 +02:00
|
|
|
|
2024-04-19 17:15:54 +02:00
|
|
|
variables = concatStringsSep " " cfg.systemd.variables;
|
|
|
|
extraCommands = concatStringsSep " && " cfg.systemd.extraCommands;
|
|
|
|
systemdActivation = ''
|
|
|
|
exec "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${variables}; ${extraCommands}"'';
|
|
|
|
|
2023-11-09 19:14:12 +01:00
|
|
|
configFile = pkgs.writeTextFile {
|
|
|
|
name = "sway.conf";
|
2023-11-09 19:19:45 +01:00
|
|
|
|
|
|
|
# Sway always does some init, see https://github.com/swaywm/sway/issues/4691
|
|
|
|
checkPhase = lib.optionalString cfg.checkConfig ''
|
|
|
|
export DBUS_SESSION_BUS_ADDRESS=/dev/null
|
|
|
|
export XDG_RUNTIME_DIR=$(mktemp -d)
|
2024-04-20 18:51:15 +02:00
|
|
|
${pkgs.xvfb-run}/bin/xvfb-run ${cfg.package}/bin/sway --config "$target" --validate --unsupported-gpu
|
2023-11-09 19:19:45 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
text = concatStringsSep "\n"
|
2023-11-09 19:14:12 +01:00
|
|
|
((optional (cfg.extraConfigEarly != "") cfg.extraConfigEarly)
|
|
|
|
++ (if cfg.config != null then
|
|
|
|
with cfg.config;
|
|
|
|
([
|
|
|
|
(fontConfigStr fonts)
|
|
|
|
"floating_modifier ${floating.modifier}"
|
|
|
|
(windowBorderString window floating)
|
|
|
|
"hide_edge_borders ${window.hideEdgeBorders}"
|
|
|
|
"focus_wrapping ${focus.wrapping}"
|
|
|
|
"focus_follows_mouse ${focus.followMouse}"
|
|
|
|
"focus_on_window_activation ${focus.newWindow}"
|
|
|
|
"mouse_warping ${
|
|
|
|
if builtins.isString (focus.mouseWarping) then
|
|
|
|
focus.mouseWarping
|
|
|
|
else if focus.mouseWarping then
|
|
|
|
"output"
|
|
|
|
else
|
|
|
|
"none"
|
|
|
|
}"
|
|
|
|
"workspace_layout ${workspaceLayout}"
|
|
|
|
"workspace_auto_back_and_forth ${
|
|
|
|
lib.hm.booleans.yesNo workspaceAutoBackAndForth
|
|
|
|
}"
|
|
|
|
"client.focused ${colorSetStr colors.focused}"
|
|
|
|
"client.focused_inactive ${colorSetStr colors.focusedInactive}"
|
|
|
|
"client.unfocused ${colorSetStr colors.unfocused}"
|
|
|
|
"client.urgent ${colorSetStr colors.urgent}"
|
|
|
|
"client.placeholder ${colorSetStr colors.placeholder}"
|
|
|
|
"client.background ${colors.background}"
|
|
|
|
(keybindingsStr {
|
|
|
|
keybindings = keybindingDefaultWorkspace;
|
|
|
|
bindsymArgs =
|
|
|
|
lib.optionalString (cfg.config.bindkeysToCode) "--to-code";
|
|
|
|
})
|
|
|
|
(keybindingsStr {
|
|
|
|
keybindings = keybindingsRest;
|
|
|
|
bindsymArgs =
|
|
|
|
lib.optionalString (cfg.config.bindkeysToCode) "--to-code";
|
|
|
|
})
|
|
|
|
(keycodebindingsStr keycodebindings)
|
|
|
|
] ++ mapAttrsToList inputStr input
|
|
|
|
++ mapAttrsToList outputStr output # outputs
|
|
|
|
++ mapAttrsToList seatStr seat # seats
|
|
|
|
++ mapAttrsToList (modeStr cfg.config.bindkeysToCode) modes # modes
|
|
|
|
++ mapAttrsToList assignStr assigns # assigns
|
|
|
|
++ map barStr bars # bars
|
|
|
|
++ optional (gaps != null) gapsStr # gaps
|
|
|
|
++ map floatingCriteriaStr floating.criteria # floating
|
|
|
|
++ map windowCommandsStr window.commands # window commands
|
|
|
|
++ map startupEntryStr startup # startup
|
|
|
|
++ map workspaceOutputStr workspaceOutputAssign # custom mapping
|
|
|
|
)
|
|
|
|
else
|
|
|
|
[ ]) ++ (optional cfg.systemd.enable systemdActivation)
|
|
|
|
++ (optional (!cfg.xwayland) "xwayland disable")
|
2023-11-09 19:19:45 +01:00
|
|
|
++ [ cfg.extraConfig ]);
|
2023-11-09 19:14:12 +01:00
|
|
|
};
|
2019-09-04 04:30:44 +02:00
|
|
|
|
|
|
|
in {
|
2023-06-10 12:10:40 +02:00
|
|
|
meta.maintainers = with maintainers; [
|
|
|
|
Scrumplex
|
|
|
|
alexarice
|
|
|
|
sumnerevans
|
|
|
|
oxalica
|
|
|
|
];
|
|
|
|
|
|
|
|
imports = let modulePath = [ "wayland" "windowManager" "sway" ];
|
|
|
|
in [
|
|
|
|
(mkRenamedOptionModule (modulePath ++ [ "systemdIntegration" ])
|
|
|
|
(modulePath ++ [ "systemd" "enable" ]))
|
|
|
|
];
|
2020-06-01 16:04:37 +02:00
|
|
|
|
2019-09-04 04:30:44 +02:00
|
|
|
options.wayland.windowManager.sway = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "sway wayland compositor";
|
2019-09-04 04:30:44 +02:00
|
|
|
|
|
|
|
package = mkOption {
|
2020-06-01 15:54:21 +02:00
|
|
|
type = with types; nullOr package;
|
2024-04-20 18:46:05 +02:00
|
|
|
default = pkgs.sway.override {
|
|
|
|
extraSessionCommands = cfg.extraSessionCommands;
|
|
|
|
extraOptions = cfg.extraOptions;
|
|
|
|
withBaseWrapper = cfg.wrapperFeatures.base;
|
|
|
|
withGtkWrapper = cfg.wrapperFeatures.gtk;
|
|
|
|
};
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "${pkgs.sway}";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-06-01 15:54:21 +02:00
|
|
|
Sway package to use. Will override the options
|
|
|
|
'wrapperFeatures', 'extraSessionCommands', and 'extraOptions'.
|
2023-07-01 01:30:13 +02:00
|
|
|
Set to `null` to not add any Sway package to your
|
2020-06-01 15:54:21 +02:00
|
|
|
path. This should be done if you want to use the NixOS Sway
|
2024-04-20 18:51:15 +02:00
|
|
|
module to install Sway. Beware setting to `null` will also disable
|
|
|
|
reloading Sway when new config is activated.
|
2019-09-04 04:30:44 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-06-10 12:10:40 +02:00
|
|
|
systemd = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = pkgs.stdenv.isLinux;
|
|
|
|
example = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 02:40:42 +02:00
|
|
|
Whether to enable {file}`sway-session.target` on
|
2023-06-10 12:10:40 +02:00
|
|
|
sway startup. This links to
|
2023-07-01 02:40:42 +02:00
|
|
|
{file}`graphical-session.target`.
|
2023-06-10 12:10:40 +02:00
|
|
|
Some important environment variables will be imported to systemd
|
|
|
|
and dbus user environment before reaching the target, including
|
2023-07-01 02:40:42 +02:00
|
|
|
* {env}`DISPLAY`
|
|
|
|
* {env}`WAYLAND_DISPLAY`
|
|
|
|
* {env}`SWAYSOCK`
|
|
|
|
* {env}`XDG_CURRENT_DESKTOP`
|
2024-04-19 17:15:54 +02:00
|
|
|
* {env}`XDG_SESSION_TYPE`
|
|
|
|
* {env}`NIXOS_OZONE_WL`
|
|
|
|
* {env}`XCURSOR_THEME`
|
|
|
|
* {env}`XCURSOR_SIZE`
|
|
|
|
You can extend this list using the `systemd.variables` option.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
variables = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [
|
|
|
|
"DISPLAY"
|
|
|
|
"WAYLAND_DISPLAY"
|
|
|
|
"SWAYSOCK"
|
|
|
|
"XDG_CURRENT_DESKTOP"
|
|
|
|
"XDG_SESSION_TYPE"
|
|
|
|
"NIXOS_OZONE_WL"
|
|
|
|
"XCURSOR_THEME"
|
|
|
|
"XCURSOR_SIZE"
|
|
|
|
];
|
2024-07-03 21:43:38 +02:00
|
|
|
example = [ "--all" ];
|
2024-04-19 17:15:54 +02:00
|
|
|
description = ''
|
|
|
|
Environment variables imported into the systemd and D-Bus user environment.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraCommands = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2024-03-07 16:48:31 +01:00
|
|
|
default = [
|
2024-03-07 17:57:22 +01:00
|
|
|
"systemctl --user reset-failed"
|
2024-03-07 16:48:31 +01:00
|
|
|
"systemctl --user start sway-session.target"
|
|
|
|
"swaymsg -mt subscribe '[]' || true"
|
|
|
|
"systemctl --user stop sway-session.target"
|
|
|
|
];
|
2024-04-19 17:15:54 +02:00
|
|
|
description = ''
|
|
|
|
Extra commands to run after D-Bus activation.
|
2023-06-10 12:10:40 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-07-02 01:45:18 +02:00
|
|
|
xdgAutostart = mkEnableOption ''
|
2023-06-10 12:10:40 +02:00
|
|
|
autostart of applications using
|
2023-07-01 01:30:13 +02:00
|
|
|
{manpage}`systemd-xdg-autostart-generator(8)`
|
2023-07-02 01:45:18 +02:00
|
|
|
'';
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
xwayland = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-09-04 04:30:44 +02:00
|
|
|
Enable xwayland, which is needed for the default configuration of sway.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
wrapperFeatures = mkOption {
|
|
|
|
type = wrapperOptions;
|
|
|
|
default = { };
|
|
|
|
example = { gtk = true; };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-09-04 04:30:44 +02:00
|
|
|
Attribute set of features to enable in the wrapper.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraSessionCommands = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
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
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-09-04 04:30:44 +02:00
|
|
|
Shell commands executed just before Sway is started.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [
|
|
|
|
"--verbose"
|
|
|
|
"--debug"
|
|
|
|
"--unsupported-gpu"
|
|
|
|
"--my-next-gpu-wont-be-nvidia"
|
|
|
|
];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-09-04 04:30:44 +02:00
|
|
|
Command line arguments passed to launch Sway. Please DO NOT report
|
|
|
|
issues if you use an unsupported GPU (proprietary drivers).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.nullOr configModule;
|
|
|
|
default = { };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Sway configuration options.";
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
2023-11-09 19:19:45 +01:00
|
|
|
checkConfig = mkOption {
|
|
|
|
type = types.bool;
|
2024-04-20 18:51:15 +02:00
|
|
|
default = cfg.package != null;
|
|
|
|
defaultText =
|
|
|
|
literalExpression "wayland.windowManager.sway.package != null";
|
|
|
|
description = "If enabled, validates the generated config file.";
|
2023-11-09 19:19:45 +01:00
|
|
|
};
|
|
|
|
|
2019-09-04 04:30:44 +02:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description =
|
2023-07-02 01:45:18 +02:00
|
|
|
"Extra configuration lines to add to ~/.config/sway/config.";
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
2022-08-27 06:09:46 +02:00
|
|
|
|
|
|
|
extraConfigEarly = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-02 01:45:18 +02:00
|
|
|
description =
|
2022-08-27 06:09:46 +02:00
|
|
|
"Like extraConfig, except lines are added to ~/.config/sway/config before all other configuration.";
|
|
|
|
};
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
2021-05-07 23:39:10 +02:00
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
(mkIf (cfg.config != null) {
|
|
|
|
warnings = (optional (isList cfg.config.fonts)
|
|
|
|
"Specifying sway.config.fonts as a list is deprecated. Use the attrset version instead.")
|
|
|
|
++ flatten (map (b:
|
|
|
|
optional (isList b.fonts)
|
|
|
|
"Specifying sway.config.bars[].fonts as a list is deprecated. Use the attrset version instead.")
|
2023-01-15 19:20:13 +01:00
|
|
|
cfg.config.bars) ++ [
|
|
|
|
(mkIf cfg.config.focus.forceWrapping
|
|
|
|
"sway.config.focus.forceWrapping is deprecated, use focus.wrapping instead.")
|
|
|
|
];
|
2021-05-07 23:39:10 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
{
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "wayland.windowManager.sway" pkgs
|
|
|
|
platforms.linux)
|
2024-04-20 18:51:15 +02:00
|
|
|
{
|
|
|
|
assertion = cfg.checkConfig -> cfg.package != null;
|
|
|
|
message =
|
|
|
|
"programs.sway.checkConfig requires non-null programs.sway.package";
|
|
|
|
}
|
2021-07-07 23:24:27 +02:00
|
|
|
];
|
|
|
|
|
2021-05-07 23:39:10 +02:00
|
|
|
home.packages = optional (cfg.package != null) cfg.package
|
|
|
|
++ optional cfg.xwayland pkgs.xwayland;
|
2021-07-07 23:24:27 +02:00
|
|
|
|
2023-11-09 19:19:45 +01:00
|
|
|
xdg.configFile."sway/config" = {
|
2021-05-07 23:39:10 +02:00
|
|
|
source = configFile;
|
2024-04-20 18:51:15 +02:00
|
|
|
onChange = lib.optionalString (cfg.package != null) ''
|
2022-04-24 23:38:50 +02:00
|
|
|
swaySocket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep --uid $UID -x sway || true).sock"
|
|
|
|
if [ -S "$swaySocket" ]; then
|
2024-04-20 18:51:15 +02:00
|
|
|
${cfg.package}/bin/swaymsg -s $swaySocket reload
|
2021-05-07 23:39:10 +02:00
|
|
|
fi
|
|
|
|
'';
|
2019-09-04 04:30:44 +02:00
|
|
|
};
|
2021-07-07 23:24:27 +02:00
|
|
|
|
2023-06-10 12:10:40 +02:00
|
|
|
systemd.user.targets.sway-session = mkIf cfg.systemd.enable {
|
2021-05-07 23:39:10 +02:00
|
|
|
Unit = {
|
|
|
|
Description = "sway compositor session";
|
|
|
|
Documentation = [ "man:systemd.special(7)" ];
|
|
|
|
BindsTo = [ "graphical-session.target" ];
|
2023-06-10 12:10:40 +02:00
|
|
|
Wants = [ "graphical-session-pre.target" ]
|
|
|
|
++ optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target";
|
2021-05-07 23:39:10 +02:00
|
|
|
After = [ "graphical-session-pre.target" ];
|
2023-06-10 12:10:40 +02:00
|
|
|
Before =
|
|
|
|
optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target";
|
2021-05-07 23:39:10 +02:00
|
|
|
};
|
|
|
|
};
|
2022-02-10 22:41:49 +01:00
|
|
|
|
|
|
|
systemd.user.targets.tray = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Home Manager System Tray";
|
|
|
|
Requires = [ "graphical-session-pre.target" ];
|
|
|
|
};
|
|
|
|
};
|
2021-05-07 23:39:10 +02:00
|
|
|
}
|
|
|
|
]);
|
2019-09-04 04:30:44 +02:00
|
|
|
}
|