2021-05-18 12:09:48 +00:00
{ pkgs , . . . }:
{
programs . sway = {
enable = true ;
wrapperFeatures . gtk = true ; # so that gtk works properly
extraPackages = with pkgs ; [
swaylock
swayidle
xwayland # for legacy apps
waybar
wl-clipboard
mako # notification daemon
alacritty # Alacritty is the default terminal in the config
2021-10-14 14:15:27 +00:00
#dmenu # Dmenu is the default in the config but i recommend wofi since its wayland native
bemenu
2021-05-18 12:09:48 +00:00
kanshi # replacement for autorandr
sway-contrib . grimshot
imv # image viewer
] ;
extraSessionCommands = ''
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
2021-10-14 14:15:27 +00:00
# firefox x11 <-> wayland interoperability
export MOZ_DBUS_REMOTE = 1
2021-05-18 12:09:48 +00:00
'' ;
} ;
#environment = {
#etc = {
## Put config files in /etc. Note that you also can put these in ~/.config, but then you can't manage them with NixOS anymore!
#"sway/config".source = ./dotfiles/sway/config;
#"xdg/waybar/config".source = ./dotfiles/waybar/config;
#"xdg/waybar/style.css".source = ./dotfiles/waybar/style.css;
#};
#};
# Here we but a shell script into path, which lets us start sway.service (after importing the environment of the login shell).
environment . systemPackages = with pkgs ; [
(
pkgs . writeTextFile {
name = " s t a r t s w a y " ;
destination = " / b i n / s t a r t s w a y " ;
executable = true ;
text = ''
#! ${pkgs.bash}/bin/bash
# first import environment variables from the login manager
systemctl - - user import-environment
# then start the service
exec systemctl - - user start sway . service
'' ;
}
)
] ;
# use gdm for authentication
services . xserver . enable = true ;
2021-10-14 14:15:27 +00:00
#services.xserver.displayManager.gdm = {
#enable = true;
#wayland = true;
#};
services . xserver . displayManager . sddm = {
2021-05-18 12:09:48 +00:00
enable = true ;
} ;
2021-10-14 14:15:27 +00:00
services . xserver . desktopManager . plasma5 = {
enable = true ;
} ;
#environment.variables = {
#GDK_SCALE = "2";
#GDK_DPI_SCALE = "0.5";
#_JAVA_OPTIONS = "-Dsun.java2d.uiScale=2";
#};
2021-05-18 12:09:48 +00:00
services . redshift = {
enable = true ;
# Redshift with wayland support isn't present in nixos-19.09 atm. You have to cherry-pick the commit from https://github.com/NixOS/nixpkgs/pull/68285 to do that.
package = pkgs . redshift-wlr ;
temperature . night = 3500 ;
} ;
systemd . user . targets . sway-session = {
description = " S w a y c o m p o s i t o r s e s s i o n " ;
documentation = [ " m a n : s y s t e m d . s p e c i a l ( 7 ) " ] ;
bindsTo = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
wants = [ " g r a p h i c a l - s e s s i o n - p r e . t a r g e t " ] ;
after = [ " g r a p h i c a l - s e s s i o n - p r e . t a r g e t " ] ;
} ;
systemd . user . services . sway = {
description = " S w a y - W a y l a n d w i n d o w m a n a g e r " ;
documentation = [ " m a n : s w a y ( 5 ) " ] ;
bindsTo = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
wants = [ " g r a p h i c a l - s e s s i o n - p r e . t a r g e t " ] ;
after = [ " g r a p h i c a l - s e s s i o n - p r e . t a r g e t " ] ;
# We explicitly unset PATH here, as we want it to be set by
# systemctl --user import-environment in startsway
environment . PATH = pkgs . lib . mkForce null ;
serviceConfig = {
Type = " s i m p l e " ;
ExecStart = ''
$ { pkgs . dbus } /bin/dbus-run-session $ { pkgs . sway } /bin/sway - - debug
'' ;
Restart = " o n - f a i l u r e " ;
RestartSec = 1 ;
TimeoutStopSec = 10 ;
} ;
} ;
systemd . user . services . swayidle = {
description = " I d l e M a n a g e r f o r W a y l a n d " ;
documentation = [ " m a n : s w a y i d l e ( 1 ) " ] ;
wantedBy = [ " s w a y - s e s s i o n . t a r g e t " ] ;
partOf = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
path = [ pkgs . bash ] ;
serviceConfig = {
ExecStart = '' ${ pkgs . swayidle } / b i n / s w a y i d l e - w - d \
timeout 300 ' $ { pkgs . sway } /bin/swaymsg " o u t p u t * d p m s o f f " ' \
resume ' $ { pkgs . sway } /bin/swaymsg " o u t p u t * d p m s o n " '
'' ;
} ;
} ;
programs . waybar . enable = true ;
systemd . user . services . kanshi = {
description = " K a n s h i o u t p u t a u t o c o n f i g " ;
wantedBy = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
partOf = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
serviceConfig = {
# kanshi doesn't have an option to specifiy config file yet, so it looks
# at .config/kanshi/config
ExecStart = ''
$ { pkgs . kanshi } /bin/kanshi
'' ;
RestartSec = 5 ;
Restart = " a l w a y s " ;
} ;
} ;
}