move sway to module

This commit is contained in:
Max Känner 2024-03-06 23:02:59 +01:00
parent fac8cb3be4
commit b655dafce9
4 changed files with 303 additions and 210 deletions

View File

@ -10,6 +10,8 @@
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# sway as window manager
../../modules/nixos/sway.nix
inputs.home-manager.nixosModules.default inputs.home-manager.nixosModules.default
]; ];

View File

@ -4,6 +4,11 @@
lib, lib,
... ...
}: { }: {
imports = [
# sway as windowmanager
../../modules/home-manager/sway.nix
];
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
home.username = "max"; home.username = "max";
@ -26,14 +31,12 @@
zsh zsh
starship starship
zoxide zoxide
nerdfonts
lazygit lazygit
btop btop
bat bat
eza eza
unzip unzip
rustup rustup
keepassxc
nextcloud-client nextcloud-client
firefox firefox
thunderbird thunderbird
@ -52,31 +55,8 @@
betaflight-configurator betaflight-configurator
loudgain loudgain
youtube-dl youtube-dl
foot
grimblast
dconf dconf
distrobox distrobox
# TODO: move into luhsoccer baguette dev environment
cmake
ninja
zip
unzip
curl
pkg-config
python3
wayland-protocols
libxkbcommon
xorg.libX11
xorg.libXrandr
xorg.libXinerama
xorg.libXcursor
xorg.libXi
xorg.libXext
xorg.xorgproto
libGL
libGLU
extra-cmake-modules
glfw
]; ];
# Home Manager is pretty good at managing dotfiles. The primary way to manage # Home Manager is pretty good at managing dotfiles. The primary way to manage
@ -113,151 +93,6 @@
EDITOR = "nvim"; EDITOR = "nvim";
}; };
wayland.windowManager.sway = {
enable = true;
systemd = {
enable = true;
xdgAutostart = true;
};
wrapperFeatures = {
gtk = true;
};
config = {
output = {
"HDMI-A-1" = {
mode = "3840x2160@60Hz";
};
};
input = {
"*" = {
xkb_layout = "de";
xkb_options = "caps:ctrl_modifier";
xkb_numlock = "enable";
};
"type:touchpad" = {
tap = "enable";
natural_scroll = "enable";
};
};
modifier = "Mod4";
keybindings = let
modifier = config.wayland.windowManager.sway.config.modifier;
in
lib.mkOptionDefault {
"${modifier}+F12" = "mode pause-break";
};
# use foot as default terminal
terminal = "foot";
assigns = {
"1" = [{app_id = "firefox";}];
"2" = [{app_id = "foot";}];
};
bars = [];
menu = "${pkgs.tofi}/bin/tofi-drun | ${pkgs.findutils}/bin/xargs swaymsg exec --";
fonts = {
names = ["FiraCode Nerd Font"];
size = 11.0;
};
modes = {
pause-break = {
e = "exec --no-startup-id swaymsg exit, mode default";
s = "exec --no-startup-id ${pkgs.dash}/bin/dash -c '${pkgs.swaylock}/bin/swaylock & systemctl suspend-then-hibernate', mode default";
r = "exec --no-startup-id systemctl reboot";
End = "exec --no-startup-id systemctl poweroff";
Return = "mode default";
Escape = "mode default";
};
};
startup = [
{command = "${pkgs.keepassxc}/bin/keepassxc";}
{command = "${pkgs.waybar}/bin/waybar";}
{command = "${pkgs.foot}/bin/foot";}
{command = "${pkgs.firefox}/bin/firefox";}
];
};
};
programs.waybar = {
enable = true;
settings = {
mainBar = {
layer = "top";
position = "top";
height = 26;
modules-left = ["sway/workspaces" "sway/mode"];
modules-right = ["sway/language" "clock" "battery"];
"sway/language" = {
format = "{shortDescription}";
tooltip = false;
};
"clock" = {
interval = 60;
format = "{:%a %d.%m %I:%M}";
};
};
};
style = ''
* {
border: none;
border-radius: 0;
padding: 0;
margin: 0;
font-size: 11px;
}
window#waybar {
background: #292828;
color: #ffffff;
}
#workspaces button {
margin-right: 10px;
color: #ffffff;
}
#workspaces button:hover, #workspaces button:active {
background-color: #292828;
color: #ffffff;
}
#workspaces button.focused {
background-color: #383737;
}
#language {
margin-right: 7px;
}
#battery {
margin-left: 7px;
margin-right: 3px;
}
'';
};
services.kanshi = {
enable = true;
profiles = {
docker_luhbots = {
outputs = [
{
criteria = "eDP-1";
position = "0,1080";
}
{
criteria = "Dell Inc. DELL U2422HE GRCPH83";
position = "0,0";
}
{
criteria = "NEC Corporation E243WMi 7X313185NB";
transform = "90";
position = "1920,0";
}
];
};
};
};
programs.zsh = { programs.zsh = {
enable = true; enable = true;
enableAutosuggestions = true; enableAutosuggestions = true;
@ -319,46 +154,6 @@
options = ["--cmd cd"]; options = ["--cmd cd"];
}; };
# Theming
gtk = {
enable = true;
cursorTheme = {
package = pkgs.capitaine-cursors;
name = "capitaine-cursors-white";
size = 24;
};
iconTheme = {
package = pkgs.whitesur-icon-theme;
name = "WhiteSur-dark";
};
theme = {
package = pkgs.whitesur-gtk-theme;
name = "WhiteSur-Dark";
};
gtk3.extraConfig = {
gtk-dialogs-use-header = false;
gtk-cursor-theme-size = 0;
gtk-toolbar-style = "GTK_TOOLBAR_BOTH_HORIZ";
gtk-toolbar-icon-style = "GTK_ICON_SIZE_LARGE_TOOLBAR";
gtk-button-images = 0;
gtk-menu-images = 0;
gtk-enable-event-sounds = 0;
gtk-enable-input-feedback-sounds = 1;
gtk-xft-antialias = 1;
gtk-xft-hinting = 1;
gtk-xft-hintstyle = "hintslight";
gtk-xft-rgba = "none";
};
};
home.pointerCursor = {
package = pkgs.capitaine-cursors;
name = "capitaine-cursors-white";
size = 24;
x11.enable = true;
x11.defaultCursor = "capitaine-cursors-white";
};
xsession.enable = true;
services.nextcloud-client.enable = true; services.nextcloud-client.enable = true;
services.mpd = { services.mpd = {

View File

@ -0,0 +1,211 @@
{
config,
pkgs,
lib,
...
}: {
home.packages = with pkgs; [
sway
waybar # status bar
swaylock # screen locking
swayidle # automatic screen locking after system idle time
kanshi # hotswap displays
foot # terminal
keepassxc # used for secrets instead of gnome-keyring
];
wayland.windowManager.sway = {
enable = true;
systemd = {
enable = true;
xdgAutostart = true;
};
wrapperFeatures = {
gtk = true;
};
config = {
input = {
"*" = {
xkb_layout = "de";
xkb_options = "caps:ctrl_modifier";
xkb_numlock = "enable";
};
"type:touchpad" = {
tap = "enable";
natural_scroll = "enable";
};
};
modifier = "Mod4";
keybindings = let
modifier = config.wayland.windowManager.sway.config.modifier;
in
lib.mkOptionDefault {
# brightness
"XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5";
"XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5";
# volume
"XF86AudioRaiseVolume" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +1%'";
"XF86AudioLowerVolume" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -1%'";
"XF86AudioMute" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle'";
# custom pause mode similar to typical system shutdown menus
"${modifier}+F12" = "mode pause-break";
};
# use foot as default terminal
terminal = "foot";
assigns = {
"1" = [{app_id = "firefox";}];
"2" = [{app_id = "foot";}];
};
bars = [];
menu = "${pkgs.tofi}/bin/tofi-drun | ${pkgs.findutils}/bin/xargs swaymsg exec --";
fonts = {
names = ["FiraCode Nerd Font"];
size = 11.0;
};
modes = {
pause-break = {
e = "exec --no-startup-id swaymsg exit, mode default";
s = "exec --no-startup-id ${pkgs.dash}/bin/dash -c '${pkgs.swaylock}/bin/swaylock & systemctl suspend-then-hibernate', mode default";
r = "exec --no-startup-id systemctl reboot";
End = "exec --no-startup-id systemctl poweroff";
Return = "mode default";
Escape = "mode default";
};
};
startup = [
{command = "${pkgs.keepassxc}/bin/keepassxc";}
{command = "${pkgs.waybar}/bin/waybar";}
{command = "${pkgs.foot}/bin/foot";}
{command = "${pkgs.firefox}/bin/firefox";}
];
};
};
programs.waybar = {
enable = true;
settings = {
mainBar = {
layer = "top";
position = "top";
height = 26;
modules-left = ["sway/workspaces" "sway/mode"];
modules-right = ["sway/language" "clock" "battery"];
"sway/language" = {
format = "{shortDescription}";
tooltip = false;
};
"clock" = {
interval = 60;
format = "{:%a %d.%m %I:%M}";
};
};
};
style = ''
* {
border: none;
border-radius: 0;
padding: 0;
margin: 0;
font-size: 11px;
}
window#waybar {
background: #292828;
color: #ffffff;
}
#workspaces button {
margin-right: 10px;
color: #ffffff;
}
#workspaces button:hover, #workspaces button:active {
background-color: #292828;
color: #ffffff;
}
#workspaces button.focused {
background-color: #383737;
}
#language {
margin-right: 7px;
}
#battery {
margin-left: 7px;
margin-right: 3px;
}
'';
};
services.kanshi = {
enable = true;
profiles = {
laptop.outputs = [
{
criteria = "eDP-1";
position = "0,0";
}
];
dock_luhbots.outputs = [
{
criteria = "eDP-1";
position = "0,1080";
}
{
criteria = "Dell Inc. DELL U2422HE GRCPH83";
position = "0,0";
}
{
criteria = "NEC Corporation E243WMi 7X313185NB";
transform = "90";
position = "1920,0";
}
];
};
};
# Theming
gtk = {
enable = true;
cursorTheme = {
package = pkgs.capitaine-cursors;
name = "capitaine-cursors-white";
size = 24;
};
iconTheme = {
package = pkgs.whitesur-icon-theme;
name = "WhiteSur-dark";
};
theme = {
package = pkgs.whitesur-gtk-theme;
name = "WhiteSur-Dark";
};
gtk3.extraConfig = {
gtk-dialogs-use-header = false;
gtk-cursor-theme-size = 0;
gtk-toolbar-style = "GTK_TOOLBAR_BOTH_HORIZ";
gtk-toolbar-icon-style = "GTK_ICON_SIZE_LARGE_TOOLBAR";
gtk-button-images = 0;
gtk-menu-images = 0;
gtk-enable-event-sounds = 0;
gtk-enable-input-feedback-sounds = 1;
gtk-xft-antialias = 1;
gtk-xft-hinting = 1;
gtk-xft-hintstyle = "hintslight";
gtk-xft-rgba = "none";
};
};
home.pointerCursor = {
package = pkgs.capitaine-cursors;
name = "capitaine-cursors-white";
size = 24;
x11.enable = true;
x11.defaultCursor = "capitaine-cursors-white";
};
xsession.enable = true;
}

85
modules/nixos/sway.nix Normal file
View File

@ -0,0 +1,85 @@
{
config,
pkgs,
lib,
...
}: let
# bash script to let dbus know about impotant env variables and
# propagate them to relevent services run at the end of sway config
dbus-sway-environment = pkgs.writeTextFile {
name = "dubs-sway-environment";
destination = "/bin/dbus-sway-environment";
executable = true;
text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
'';
};
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in ''
gnome_schema=org.gnome.desktop.interface
gsettings set $gnome_schema gtk-theme 'Dracula'
'';
};
in {
environment.systemPackages = with pkgs; [
dbus # make dbus-update-activation-environment available in the path
dbus-sway-environment
configure-gtk
wayland
xdg-utils # for opening default programs when clicking links
glib # gsettings
dracula-theme # gtk theme
gnome3.adwaita-icon-theme # default gnome cursors
swaylock
swayidle
grim # screenshot functionality
slurp # screenshot functionality
wl-clipboard # wl-copy and wl-paste for copy/paste from stdin/stdout
mako # notification system developed by swaywm maintainer
wdisplays # tool to configure displays
];
services.pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
jack.enable = true;
};
# xdg-desktop-portal works by exposing a series of D-Bus interfaces
# known as portals under a well-known name
# (org.freedesktop.portal.Desktop) and object path
# (/org/freedesktop/portal/desktop).
# The portal interfaces include APIs for file access, opening URIs,
# printing and others.
services.dbus.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true;
# gtk portal needed to make gtk apps happy
extraPortals = [pkgs.xdg-desktop-portal-gtk];
};
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
# make brightness keys work
users.users.max.extraGroups = ["video"];
programs.light.enable = true;
# make swaylock work
security.pam.services.swaylock = {};
}