214 lines
5.5 KiB
Nix
214 lines
5.5 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 {
|
|
|
|
# enable nix module
|
|
programs.hyprland = {
|
|
enable = true;
|
|
package = null; # because we use the home-manager module
|
|
};
|
|
|
|
# enable home-manager module
|
|
home-manager.users.moritz = {
|
|
# import home-manager module
|
|
imports = [ inputs.hyprland.homeManagerModules.default ];
|
|
|
|
wayland.windowManager.hyprland = {
|
|
enable = true;
|
|
package = hyprland;
|
|
extraConfig = import ./config.nix args;
|
|
};
|
|
};
|
|
|
|
|
|
# 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;
|
|
target = "hyprland-session.target";
|
|
};
|
|
|
|
settings = {
|
|
mainBar = {
|
|
layer = "top";
|
|
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";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
# 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 = {
|
|
enable = true;
|
|
path = [ pkgs.hyprpaper ];
|
|
wantedBy = [ "hyprland-session.target" ];
|
|
after = [ "hyprland-session.target" ];
|
|
script = "hyprpaper";
|
|
};
|
|
|
|
# set hyprpaper conf (for setting initial background)
|
|
home-manager.users.moritz.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" ];
|
|
before = [ "graphical-session.target" ];
|
|
};
|
|
|
|
|
|
# add user packages for wayland and hyprland in particular
|
|
users.users.moritz.packages = with pkgs; [
|
|
# pulse audio cli
|
|
pamixer
|
|
# control media playback
|
|
playerctl
|
|
# control brightness
|
|
brightnessctl
|
|
# screenshot tool for hyprland
|
|
grimblast
|
|
# region select for wayland (for screensharing)
|
|
slurp
|
|
# clipboard tool for wayland
|
|
wl-clipboard
|
|
];
|
|
|
|
|
|
# additional environment variables
|
|
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";
|
|
} // (optionalAttrs cfg.nvidiaSupport
|
|
{
|
|
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";
|
|
});
|
|
|
|
|
|
services = {
|
|
dbus.enable = true;
|
|
# use pipewire (needed for screensharing)
|
|
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 ]; # can't set the defaultSession otherwise
|
|
};
|
|
};
|
|
};
|
|
security.rtkit.enable = true;
|
|
|
|
|
|
# dekstop portal (for screensharing)
|
|
xdg.portal = {
|
|
enable = true;
|
|
wlr.enable = true;
|
|
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
|
|
};
|
|
};
|
|
}
|