dotfiles/modules/programs/hyprland/default.nix
2023-01-26 10:55:27 +01:00

178 lines
4.4 KiB
Nix

{ config
, lib
, pkgs
, inputs
, ...
} @ args:
with lib;
let
cfg = config.my.programs.hyprland;
hyprland = pkgs.hyprland.override { nvidiaPatches = cfg.nvidiaSupport; };
in
{
options.my.programs.hyprland = {
enable = mkEnableOption "hyprland";
nvidiaSupport = mkEnableOption "enable nvidia Support";
};
config = mkIf cfg.enable {
my = {
programs = {
kitty.enable = true;
rofi.enable = true;
};
services.dunst.enable = true;
};
home-manager.users.moritz = {
imports = [ inputs.hyprland.homeManagerModules.default ];
programs.waybar = {
enable = true;
package = pkgs.waybar-hyprland;
systemd = {
enable = true;
target = "hyprland-session.target";
};
settings = {
mainBar = {
layer = "top";
position = "top";
height = 30;
modules-left = [ "wlr/workspaces" ];
modules-center = [ "hyprland/window" ];
modules-right = [ "network" "memory" "cpu" "battery" "clock" ];
modules = {
"wlr/workspaces" = {
on-click = "activate";
};
};
};
};
};
wayland.windowManager.hyprland = {
enable = true;
package = hyprland;
extraConfig = import ./config.nix args;
};
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" ];
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";
};
};
systemd.user.services.hyprpaper = {
enable = true;
path = [ pkgs.hyprpaper ];
wantedBy = [ "hyprland-session.target" ];
after = [ "display-manager.service" ];
script = "hyprpaper";
};
users.users.moritz.packages = with pkgs; [
swayidle
swaylock-effects
pamixer
playerctl
brightnessctl
grimblast
slurp
grim
wl-clipboard
wdisplays
];
security.pam.services.swaylock = { };
programs.hyprland = {
enable = true;
package = null;
};
environment.sessionVariables =
{
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_TYPE = "wayland";
XDG_SESSION_DESKTOP = "Hyprland";
QT_AUTO_SCREEN_SCALE_FACTOR = "1";
QT_QPA_PLATFORM = "wayland;xcb";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
QT_QPA_PLATFORMTHEME = "qt5ct";
_JAVA_AWT_WM_NONEREPARENTING = "1";
} //
(if cfg.nvidiaSupport then
{
LIBVA_DRIVER_NAME = "nvidia";
GBM_BACKEND = "nvidia-drm";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
WLR_NO_HARDWARE_CURSORS = "1";
__GL_VRR_ALLOWED = "0";
} else { });
services = {
dbus.enable = true;
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
xserver = {
enable = true;
displayManager = {
lightdm.enable = true;
autoLogin = {
enable = true;
user = "moritz";
};
defaultSession = "hyprland";
sessionPackages = [ hyprland ];
};
};
};
security.rtkit.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
};
};
}