2022-11-25 10:24:29 +01:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
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;
|
|
|
|
|
2023-10-25 17:19:26 +02:00
|
|
|
hyprland = config.programs.hyprland.finalPackage;
|
2022-11-25 10:24:29 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.programs.hyprland = {
|
|
|
|
enable = mkEnableOption "hyprland";
|
|
|
|
nvidiaSupport = mkEnableOption "enable nvidia Support";
|
2023-01-11 10:39:29 +01:00
|
|
|
blur = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
description = "enable window blurring";
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
shadows = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
description = "enable window shadows";
|
|
|
|
default = true;
|
|
|
|
};
|
2023-06-25 10:58:39 +02:00
|
|
|
keyboardLayouts = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "list of keyboard layouts";
|
|
|
|
default = [ "de" "us" ];
|
|
|
|
};
|
2023-09-22 10:14:12 +02:00
|
|
|
monitors = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "monitor settings";
|
|
|
|
default = [ ",preferred,auto,1" ];
|
|
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
};
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-01-26 10:55:27 +01:00
|
|
|
my = {
|
|
|
|
programs = {
|
2023-05-08 12:54:21 +02:00
|
|
|
wallpaper.enable = true;
|
2023-01-26 10:55:27 +01:00
|
|
|
kitty.enable = true;
|
|
|
|
rofi.enable = true;
|
|
|
|
};
|
2023-05-08 12:54:21 +02:00
|
|
|
wallpapers.enable = true;
|
2023-10-25 17:19:26 +02:00
|
|
|
services = {
|
|
|
|
dunst.enable = true;
|
|
|
|
wallpaper = {
|
|
|
|
enable = true;
|
|
|
|
target = "hyprland-session.target";
|
|
|
|
};
|
|
|
|
spotify-player.target = "hyprland-session.target";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.hyprland = {
|
|
|
|
enable = true;
|
|
|
|
enableNvidiaPatches = cfg.nvidiaSupport;
|
2023-01-26 10:55:27 +01:00
|
|
|
};
|
|
|
|
|
2022-11-25 10:24:29 +01:00
|
|
|
home-manager.users.moritz = {
|
2023-09-27 12:38:41 +02:00
|
|
|
# enable home-manager module
|
2022-11-25 10:24:29 +01:00
|
|
|
wayland.windowManager.hyprland = {
|
|
|
|
enable = true;
|
2023-10-25 17:19:26 +02:00
|
|
|
enableNvidiaPatches = cfg.nvidiaSupport;
|
2023-05-11 17:33:14 +02:00
|
|
|
extraConfig = import ./_config.nix args;
|
2023-10-25 17:19:26 +02:00
|
|
|
systemd.extraCommands = [
|
|
|
|
"systemctl --user stop hyprland-session.target"
|
|
|
|
"sleep 1.5"
|
|
|
|
"systemctl --user start hyprland-session.target"
|
|
|
|
"systemctl --user start xdg-desktop-portal-hyprland.service"
|
|
|
|
];
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
2023-01-07 17:06:29 +01:00
|
|
|
|
2023-09-27 12:38:41 +02:00
|
|
|
# add waybar as a status bar
|
|
|
|
programs.waybar = {
|
2022-11-26 16:02:02 +01:00
|
|
|
enable = true;
|
2023-01-07 17:06:29 +01:00
|
|
|
|
2023-09-27 12:38:41 +02:00
|
|
|
# start using systemd service
|
|
|
|
systemd = {
|
|
|
|
enable = true;
|
2023-10-25 17:19:26 +02:00
|
|
|
target = "hyprland-session.target";
|
2023-09-27 12:38:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
mainBar = {
|
|
|
|
start_hidden = true;
|
|
|
|
layer = "top";
|
|
|
|
position = "top";
|
|
|
|
height = 20;
|
|
|
|
modules-left = [ "hyprland/workspaces" ];
|
|
|
|
modules-center = [ "hyprland/window" ];
|
|
|
|
modules-right = [ "hyprland/language" "network" "memory" "cpu" "battery" "clock" ];
|
|
|
|
};
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
|
|
|
};
|
2022-11-26 16:02:02 +01:00
|
|
|
|
2023-09-27 12:38:41 +02:00
|
|
|
# lock screen after timeout
|
|
|
|
programs.swaylock = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
color = "000000";
|
|
|
|
};
|
2023-09-22 10:14:12 +02:00
|
|
|
};
|
2023-09-27 12:38:41 +02:00
|
|
|
services.swayidle = {
|
|
|
|
enable = true;
|
|
|
|
events = [
|
2022-11-26 16:02:02 +01:00
|
|
|
{
|
2023-09-27 12:38:41 +02:00
|
|
|
event = "before-sleep";
|
|
|
|
command = "${getExe pkgs.swaylock} -fF";
|
2022-11-26 16:02:02 +01:00
|
|
|
}
|
2023-09-22 10:14:12 +02:00
|
|
|
{
|
2023-09-27 12:38:41 +02:00
|
|
|
event = "lock";
|
|
|
|
command = "${getExe pkgs.swaylock} -fF";
|
2023-09-22 10:14:12 +02:00
|
|
|
}
|
2023-09-27 12:38:41 +02:00
|
|
|
];
|
|
|
|
timeouts =
|
|
|
|
let
|
|
|
|
lockTimeout = 10;
|
|
|
|
in
|
|
|
|
[
|
|
|
|
{
|
|
|
|
timeout = lockTimeout * 60 - 10;
|
|
|
|
command = "${pkgs.libnotify}/bin/notify-send 'Locking screen!'";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
timeout = lockTimeout * 60;
|
|
|
|
command = "${hyprland}/bin/hyprctl dispatch dpms off";
|
|
|
|
resumeCommand = "${hyprland}/bin/hyprctl dispatch dpms on";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
timeout = lockTimeout * 60 + 10;
|
|
|
|
command = "${pkgs.systemd}/bin/loginctl lock-session";
|
|
|
|
}
|
|
|
|
] ++ optional
|
|
|
|
(!cfg.nvidiaSupport) # TODO https://github.com/hyprwm/Hyprland/issues/1728
|
|
|
|
{
|
|
|
|
timeout = 30 * 60;
|
|
|
|
command = "${pkgs.systemd}/bin/systemctl suspend-and-hibernate";
|
|
|
|
};
|
2023-10-25 17:19:26 +02:00
|
|
|
systemdTarget = "hyprland-session.target";
|
2023-09-27 12:38:41 +02:00
|
|
|
};
|
2022-12-23 12:39:24 +01:00
|
|
|
};
|
2023-01-07 17:06:29 +01:00
|
|
|
|
|
|
|
# adds pam module for swaylock
|
|
|
|
security.pam.services.swaylock = { };
|
|
|
|
|
|
|
|
# add user packages for wayland and hyprland in particular
|
2022-11-26 16:02:02 +01:00
|
|
|
users.users.moritz.packages = with pkgs; [
|
2023-02-11 15:40:26 +01:00
|
|
|
brightnessctl # control brightness
|
|
|
|
grimblast # screenshot tool for hyprland
|
2023-02-26 13:33:13 +01:00
|
|
|
pamixer # pulse audio cli
|
|
|
|
playerctl # control media playback
|
2023-02-11 15:40:26 +01:00
|
|
|
slurp # region select for wayland (for screensharing)
|
2023-02-26 13:33:13 +01:00
|
|
|
wdisplays # manage monitors
|
2023-02-11 15:40:26 +01:00
|
|
|
wl-clipboard # clipboard tool for wayland
|
2022-11-26 16:02:02 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
2023-01-07 17:06:29 +01:00
|
|
|
# additional environment variables
|
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";
|
2023-01-07 17:06:29 +01:00
|
|
|
} // (optionalAttrs cfg.nvidiaSupport
|
2022-11-26 16:02:02 +01:00
|
|
|
{
|
|
|
|
LIBVA_DRIVER_NAME = "nvidia";
|
|
|
|
GBM_BACKEND = "nvidia-drm";
|
|
|
|
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
|
|
|
|
WLR_NO_HARDWARE_CURSORS = "1";
|
|
|
|
__GL_VRR_ALLOWED = "0";
|
2023-01-07 17:06:29 +01:00
|
|
|
});
|
|
|
|
|
2022-12-23 12:39:24 +01:00
|
|
|
services = {
|
|
|
|
dbus.enable = true;
|
2023-01-07 17:06:29 +01:00
|
|
|
# use pipewire (needed for screensharing)
|
2022-12-23 12:39:24 +01:00
|
|
|
pipewire = {
|
|
|
|
enable = true;
|
|
|
|
alsa.enable = true;
|
|
|
|
alsa.support32Bit = true;
|
|
|
|
pulse.enable = true;
|
|
|
|
};
|
2023-09-25 18:29:29 +02:00
|
|
|
xserver = {
|
2022-12-23 12:39:24 +01:00
|
|
|
enable = true;
|
2023-09-25 18:29:29 +02:00
|
|
|
displayManager = {
|
|
|
|
lightdm.enable = true;
|
|
|
|
autoLogin = {
|
|
|
|
enable = true;
|
|
|
|
user = "moritz";
|
2022-12-23 12:39:24 +01:00
|
|
|
};
|
2023-09-25 18:29:29 +02:00
|
|
|
defaultSession = "hyprland";
|
|
|
|
};
|
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
|
|
|
|
2023-10-25 17:19:26 +02:00
|
|
|
home-manager.users.moritz.systemd.user.services =
|
|
|
|
let
|
|
|
|
units = [ "waybar" ];
|
|
|
|
mkAfter = _: {
|
|
|
|
Unit = {
|
|
|
|
After = [ "hyprland-session.target" ];
|
|
|
|
Wants = [ "hyprland-session.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
genAttrs units mkAfter;
|
|
|
|
|
|
|
|
systemd.user.services =
|
|
|
|
let
|
|
|
|
units = [ "pipewire" "xdg-desktop-portal" "xdg-desktop-portal-hyprland" "wireplumber" ];
|
|
|
|
mkAfter = _: {
|
|
|
|
after = [ "hyprland-session.target" ];
|
|
|
|
wants = [ "hyprland-session.target" ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
genAttrs units mkAfter;
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
|
|
|
}
|