Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions modules/services/window-managers/i3-sway/sway.nix
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,6 @@ let
exec "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target"'')
++ (optional (!cfg.xwayland) "xwayland disable") ++ [ cfg.extraConfig ]));

defaultSwayPackage = pkgs.sway.override {
extraSessionCommands = cfg.extraSessionCommands;
extraOptions = cfg.extraOptions;
withBaseWrapper = cfg.wrapperFeatures.base;
withGtkWrapper = cfg.wrapperFeatures.gtk;
};

in {
meta.maintainers = with maintainers; [
Scrumplex
Expand All @@ -347,8 +340,9 @@ in {

package = mkOption {
type = with types; nullOr package;
default = defaultSwayPackage;
defaultText = literalExpression "${pkgs.sway}";
default = pkgs.sway-unwrapped;
defaultText = literalExpression "pkgs.sway-unwrapped";
example = literalExpression "pkgs.swayfx";
description = ''
Sway package to use. Will override the options
'wrapperFeatures', 'extraSessionCommands', and 'extraOptions'.
Expand All @@ -358,6 +352,13 @@ in {
'';
};

finalPackage = mkOption {
type = types.package;
visible = false;
readOnly = true;
description = "Resulting customized sway package.";
};

systemd = {
enable = mkOption {
type = types.bool;
Expand Down Expand Up @@ -476,17 +477,26 @@ in {
platforms.linux)
];

home.packages = optional (cfg.package != null) cfg.package
wayland.windowManager.sway.finalPackage = let
swayUnwrapped =
if cfg.package == null then pkgs.sway-unwrapped else cfg.package;
in pkgs.sway.override {
extraSessionCommands = cfg.extraSessionCommands;
extraOptions = cfg.extraOptions;
withBaseWrapper = cfg.wrapperFeatures.base;
withGtkWrapper = cfg.wrapperFeatures.gtk;
sway-unwrapped = swayUnwrapped;
};

home.packages = optional (cfg.package != null) cfg.finalPackage
++ optional cfg.xwayland pkgs.xwayland;

xdg.configFile."sway/config" = let
swayPackage = if cfg.package == null then pkgs.sway else cfg.package;
in {
xdg.configFile."sway/config" = {
source = configFile;
onChange = ''
swaySocket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep --uid $UID -x sway || true).sock"
if [ -S "$swaySocket" ]; then
${swayPackage}/bin/swaymsg -s $swaySocket reload
${cfg.finalPackage}/bin/swaymsg -s $swaySocket reload
fi
'';
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bar {
hidden_state hide
position bottom
status_command @i3status@/bin/i3status
swaybar_command @sway@/bin/swaybar
swaybar_command /nix/store/00000000000000000000000000000000-sway-unwrapped/bin/swaybar
workspace_buttons yes
strip_workspace_numbers no
tray_output primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
# overriding findutils causes issues
config.menu = "${pkgs.dmenu}/bin/dmenu_run";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bar {
hidden_state hide
position bottom
status_command @i3status@/bin/i3status
swaybar_command @sway@/bin/swaybar
swaybar_command /nix/store/00000000000000000000000000000000-sway-unwrapped/bin/swaybar
workspace_buttons yes
strip_workspace_numbers no
tray_output primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
# overriding findutils causes issues
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
config.bindkeysToCode = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bar {
hidden_state hide
position bottom
status_command @i3status@/bin/i3status
swaybar_command @sway@/bin/swaybar
swaybar_command /nix/store/00000000000000000000000000000000-sway-unwrapped/bin/swaybar
workspace_buttons yes
strip_workspace_numbers no
tray_output primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
# overriding findutils causes issues
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

config = {
focus.followMouse = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

config = {
focus.followMouse = "always";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bar {
hidden_state hide
position bottom
status_command @i3status@/bin/i3status
swaybar_command @sway@/bin/swaybar
swaybar_command /nix/store/00000000000000000000000000000000-sway-unwrapped/bin/swaybar
workspace_buttons yes
strip_workspace_numbers no
tray_output primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

# overriding findutils causes issues
config = {
menu = "${pkgs.dmenu}/bin/dmenu_run";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

config = null;
systemd.enable = false;
xwayland = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

config = null;
systemd.enable = false;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bar {
hidden_state hide
position bottom
status_command @i3status@/bin/i3status
swaybar_command @sway@/bin/swaybar
swaybar_command /nix/store/00000000000000000000000000000000-sway/bin/swaybar
workspace_buttons yes
strip_workspace_numbers no
tray_output primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

# overriding findutils causes issues
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
};
Expand Down
3 changes: 0 additions & 3 deletions tests/modules/services/window-managers/sway/sway-stubs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
dmenu = { };
foot = { };
i3status = { };
sway = { };
sway-unwrapped = { version = "1"; };
swaybg = { };
xwayland = { };
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bar {
hidden_state hide
position bottom
status_command @i3status@/bin/i3status
swaybar_command @sway@/bin/swaybar
swaybar_command /nix/store/00000000000000000000000000000000-sway-unwrapped/bin/swaybar
workspace_buttons yes
strip_workspace_numbers no
tray_output primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

# overriding findutils causes issues
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
config.defaultWorkspace = "workspace number 9";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bar {
hidden_state hide
position bottom
status_command @i3status@/bin/i3status
swaybar_command @sway@/bin/swaybar
swaybar_command /nix/store/00000000000000000000000000000000-sway-unwrapped/bin/swaybar
workspace_buttons yes
strip_workspace_numbers no
tray_output primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in {

wayland.windowManager.sway = {
enable = true;
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };

# overriding findutils causes issues
config.menu = "${pkgs.dmenu}/bin/dmenu_run";

Expand Down