From 2287ca24238763bae50e215a68267b29ba934c8b Mon Sep 17 00:00:00 2001 From: James Patrick Date: Tue, 30 Nov 2021 23:40:35 -0500 Subject: [PATCH] Added basic systemd for sway --- modules/sway.nix | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/modules/sway.nix b/modules/sway.nix index a336283..b801583 100644 --- a/modules/sway.nix +++ b/modules/sway.nix @@ -15,6 +15,51 @@ swaylock wl-clipboard wofi + (writeTextFile { + name = "sway-entry"; + destination = "/bin/sway-entry"; + executable = true; + text = '' + #! ${pkgs.bash}/bin/bash + + # first import environment variables from the login manager + # function is currently deprecated. It should be rolled back in the future + systemctl --user import-environment + + # then start the service + exec systemctl --user start sway.service + ''; + }) ]; }; + + systemd.user.targets.sway-session = { + description = "Sway compositor session"; + documentation = [ "man:systemd.special(7)" ]; + bindsTo = [ "graphical-session.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + }; + + systemd.user.services.sway = { + description = "Sway - Wayland window manager"; + documentation = [ "man:sway(5)" ]; + bindsTo = [ "graphical-session.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + # We explicitly unset PATH here, as we want it to be set by + # systemctl --user import-environment in startsway + environment.PATH = lib.mkForce null; + serviceConfig = { + Type = "simple"; + ExecStart = '' + ${pkgs.dbus}/bin/dbus-run-session ${pkgs.sway}/bin/sway --debug + ''; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; + }; + }; + + users.users.james.extraGroups = [ "video" "audio" ]; }