dotfiles/modules/programs/hyprland/default.nix

174 lines
4.4 KiB
Nix
Raw Normal View History

2022-11-25 10:24:29 +01:00
{ config
, lib
, pkgs
, inputs
, ...
2022-11-26 16:02:02 +01:00
} @ args:
2022-11-25 10:24:29 +01:00
with lib;
let
cfg = config.my.programs.hyprland;
2022-12-30 19:01:31 +01:00
hyprland = pkgs.hyprland.override { nvidiaPatches = cfg.nvidiaSupport; };
2022-11-25 10:24:29 +01:00
in
{
options.my.programs.hyprland = {
enable = mkEnableOption "hyprland";
nvidiaSupport = mkEnableOption "enable nvidia Support";
};
config = mkIf cfg.enable {
home-manager.users.moritz = {
imports = [ inputs.hyprland.homeManagerModules.default ];
2022-11-26 16:02:02 +01:00
2022-11-25 10:24:29 +01:00
programs.waybar = {
enable = true;
package = pkgs.waybar-hyprland;
2022-12-30 19:01:31 +01:00
systemd = {
enable = true;
target = "hyprland-session.target";
};
2022-11-25 10:24:29 +01:00
settings = {
mainBar = {
layer = "top";
position = "top";
height = 30;
output = [
"eDP-1"
"HDMI-A-1"
2022-11-26 16:02:02 +01:00
"HDMI-A-2"
2022-11-25 10:24:29 +01:00
];
modules-left = [ "wlr/workspaces" ];
modules-center = [ "hyprland/window" ];
modules-right = [ "network" "memory" "cpu" "battery" "clock" ];
modules = {
"wlr/workspaces" = {
on-click = "activate";
};
};
};
};
};
2022-11-26 16:02:02 +01:00
2022-11-25 10:24:29 +01:00
wayland.windowManager.hyprland = {
enable = true;
package = hyprland;
2022-11-26 16:02:02 +01:00
extraConfig = import ./config.nix args;
2022-11-25 10:24:29 +01:00
};
2022-11-26 16:02:02 +01:00
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" ];
2022-12-23 12:39:24 +01:00
xdg.configFile."hypr/hyprpaper.conf" = {
text =
let
setWallpaper = wallpaper: ''
preload = ${wallpaper}
wallpaper = ,${wallpaper}
'';
in
2022-12-30 19:01:31 +01:00
setWallpaper "/home/moritz/.config/wallpapers/a_short_walk.png";
2022-12-23 12:39:24 +01:00
onChange = "${pkgs.systemd}/bin/systemctl restart --user hyprpaper.service";
};
};
systemd.user.services.hyprpaper = {
enable = true;
path = [ pkgs.hyprpaper ];
2022-12-30 19:01:31 +01:00
wantedBy = [ "hyprland-session.target" ];
2022-12-23 12:39:24 +01:00
after = [ "display-manager.service" ];
script = "hyprpaper";
2022-11-25 10:24:29 +01:00
};
2022-11-26 16:02:02 +01:00
users.users.moritz.packages = with pkgs; [
swayidle
swaylock-effects
pamixer
playerctl
brightnessctl
2023-01-01 15:27:31 +01:00
grimblast
wl-clipboard
2022-11-26 16:02:02 +01:00
];
security.pam.services.swaylock = { };
2022-11-25 10:24:29 +01:00
programs.hyprland = {
enable = true;
package = null;
};
2022-11-26 16:02:02 +01:00
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";
XDG_SESSION_TYPE = "wayland";
GBM_BACKEND = "nvidia-drm";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
WLR_NO_HARDWARE_CURSORS = "1";
__GL_VRR_ALLOWED = "0";
} else { });
2022-12-23 12:39:24 +01:00
services = {
dbus.enable = true;
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
xserver = {
enable = true;
displayManager = {
2023-01-02 16:17:38 +01:00
lightdm.enable = true;
2022-12-23 12:39:24 +01:00
autoLogin = {
enable = true;
user = "moritz";
};
defaultSession = "hyprland";
sessionPackages = [ hyprland ];
2022-11-26 16:02:02 +01:00
};
2022-11-25 10:24:29 +01:00
};
};
2022-12-23 12:39:24 +01:00
security.rtkit.enable = true;
2022-11-26 16:02:02 +01:00
2022-11-25 10:24:29 +01:00
xdg.portal = {
enable = true;
wlr.enable = true;
2022-12-30 19:01:31 +01:00
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
2022-11-25 10:24:29 +01:00
};
};
}