add comments

This commit is contained in:
Moritz Böhme 2023-01-07 17:06:29 +01:00
parent d4ce7ee5d3
commit b945c25157
Signed by: moritz
GPG key ID: 970C6E89EB0547A9

View file

@ -18,108 +18,141 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz = {
imports = [ inputs.hyprland.homeManagerModules.default ];
programs.waybar = { # enable nix module
enable = true; programs.hyprland = {
package = pkgs.waybar-hyprland; enable = true;
systemd = { package = null; # because we use the home-manager module
enable = true; };
target = "hyprland-session.target";
}; # enable home-manager module
settings = { home-manager.users.moritz = {
mainBar = { # import home-manager module
layer = "top"; imports = [ inputs.hyprland.homeManagerModules.default ];
position = "top";
height = 30;
output = [
"eDP-1"
"HDMI-A-1"
"HDMI-A-2"
];
modules-left = [ "wlr/workspaces" ];
modules-center = [ "hyprland/window" ];
modules-right = [ "network" "memory" "cpu" "battery" "clock" ];
modules = {
"wlr/workspaces" = {
on-click = "activate";
};
};
};
};
};
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
package = hyprland; package = hyprland;
extraConfig = import ./config.nix args; extraConfig = import ./config.nix args;
}; };
};
services.swayidle = {
# add waybar as a status bar
home-manager.users.moritz.programs.waybar = {
enable = true;
# use package with hyprland support for switching workspaces
package = pkgs.waybar-hyprland;
# start using systemd service
systemd = {
enable = true; enable = true;
events = [ target = "hyprland-session.target";
{
event = "before-sleep";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF";
}
{
event = "lock";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF";
}
];
timeouts = [
{
timeout = 300;
command = "${hyprland}/bin/hyprctl dispatch dpms off";
resumeCommand = "${hyprland}/bin/hyprctl dispatch dpms on";
}
{
timeout = 310;
command = "${pkgs.systemd}/bin/loginctl lock-session";
}
];
}; };
# start swayidle as part of hyprland, not sway
systemd.user.services.swayidle.Install.WantedBy = lib.mkForce [ "hyprland-session.target" ];
xdg.configFile."hypr/hyprpaper.conf" = { settings = {
text = mainBar = {
let layer = "top";
setWallpaper = wallpaper: '' position = "top";
preload = ${wallpaper} height = 30;
wallpaper = ,${wallpaper} output = [
''; "eDP-1"
in "HDMI-A-1"
setWallpaper "/home/moritz/.config/wallpapers/a_short_walk.png"; "HDMI-A-2"
onChange = "${pkgs.systemd}/bin/systemctl restart --user hyprpaper.service"; ];
modules-left = [ "wlr/workspaces" ];
modules-center = [ "hyprland/window" ];
modules-right = [ "network" "memory" "cpu" "battery" "clock" ];
modules = {
"wlr/workspaces" = {
on-click = "activate";
};
};
};
}; };
}; };
# lock screen after timeout
home-manager.users.moritz.services.swayidle = {
enable = true;
events = [
{
event = "before-sleep";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF";
}
{
event = "lock";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF";
}
];
timeouts = [
{
timeout = 300;
command = "${hyprland}/bin/hyprctl dispatch dpms off";
resumeCommand = "${hyprland}/bin/hyprctl dispatch dpms on";
}
{
timeout = 310;
command = "${pkgs.systemd}/bin/loginctl lock-session";
}
];
};
# start swayidle as part of hyprland, not sway
systemd.user.services.swayidle.Install.WantedBy = lib.mkForce [ "hyprland-session.target" ];
# adds pam module for swaylock
security.pam.services.swaylock = { };
# start hyprpaper daemon using systemd unit (to set wallpaper)
systemd.user.services.hyprpaper = { systemd.user.services.hyprpaper = {
enable = true; enable = true;
path = [ pkgs.hyprpaper ]; path = [ pkgs.hyprpaper ];
wantedBy = [ "hyprland-session.target" ]; wantedBy = [ "hyprland-session.target" ];
after = [ "display-manager.service" ]; after = [ "hyprland-session.target" ];
script = "hyprpaper"; script = "hyprpaper";
}; };
# set hyprpaper conf (for setting initial background)
xdg.configFile."hypr/hyprpaper.conf" = {
text =
let
setWallpaper = wallpaper: ''
preload = ${wallpaper}
wallpaper = ,${wallpaper}
'';
in
setWallpaper "/home/moritz/.config/wallpapers/a_short_walk.png";
onChange = "${pkgs.systemd}/bin/systemctl restart --user hyprpaper.service";
};
# only consider graphical-session.target started when hyprland-sesstion.target is reached
systemd.user.targets.hyprland-session = {
wantedBy = [ "graphical-session.target" ];
};
# add user packages for wayland and hyprland in particular
users.users.moritz.packages = with pkgs; [ users.users.moritz.packages = with pkgs; [
swayidle # pulse audio cli
swaylock-effects
pamixer pamixer
# control media playback
playerctl playerctl
# control brightness
brightnessctl brightnessctl
# screenshot tool for hyprland
grimblast grimblast
# region select for wayland (for screensharing)
slurp
# clipboard tool for wayland
wl-clipboard wl-clipboard
]; ];
security.pam.services.swaylock = { };
programs.hyprland = {
enable = true;
package = null;
};
# additional environment variables
environment.sessionVariables = environment.sessionVariables =
{ {
XDG_CURRENT_DESKTOP = "Hyprland"; XDG_CURRENT_DESKTOP = "Hyprland";
@ -130,8 +163,7 @@ in
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
QT_QPA_PLATFORMTHEME = "qt5ct"; QT_QPA_PLATFORMTHEME = "qt5ct";
_JAVA_AWT_WM_NONEREPARENTING = "1"; _JAVA_AWT_WM_NONEREPARENTING = "1";
} // } // (optionalAttrs cfg.nvidiaSupport
(if cfg.nvidiaSupport then
{ {
LIBVA_DRIVER_NAME = "nvidia"; LIBVA_DRIVER_NAME = "nvidia";
XDG_SESSION_TYPE = "wayland"; XDG_SESSION_TYPE = "wayland";
@ -139,10 +171,12 @@ in
__GLX_VENDOR_LIBRARY_NAME = "nvidia"; __GLX_VENDOR_LIBRARY_NAME = "nvidia";
WLR_NO_HARDWARE_CURSORS = "1"; WLR_NO_HARDWARE_CURSORS = "1";
__GL_VRR_ALLOWED = "0"; __GL_VRR_ALLOWED = "0";
} else { }); });
services = { services = {
dbus.enable = true; dbus.enable = true;
# use pipewire (needed for screensharing)
pipewire = { pipewire = {
enable = true; enable = true;
alsa.enable = true; alsa.enable = true;
@ -158,12 +192,14 @@ in
user = "moritz"; user = "moritz";
}; };
defaultSession = "hyprland"; defaultSession = "hyprland";
sessionPackages = [ hyprland ]; sessionPackages = [ hyprland ]; # can't set the defaultSession otherwise
}; };
}; };
}; };
security.rtkit.enable = true; security.rtkit.enable = true;
# dekstop portal (for screensharing)
xdg.portal = { xdg.portal = {
enable = true; enable = true;
wlr.enable = true; wlr.enable = true;