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";
|
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;
|
|
|
|
};
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-01-26 10:55:27 +01:00
|
|
|
my = {
|
|
|
|
programs = {
|
|
|
|
kitty.enable = true;
|
|
|
|
rofi.enable = true;
|
|
|
|
};
|
|
|
|
services.dunst.enable = true;
|
|
|
|
};
|
|
|
|
|
2023-01-07 17:06:29 +01:00
|
|
|
# enable home-manager module
|
2022-11-25 10:24:29 +01:00
|
|
|
home-manager.users.moritz = {
|
2023-01-07 17:06:29 +01:00
|
|
|
# import home-manager module
|
2022-11-25 10:24:29 +01:00
|
|
|
imports = [ inputs.hyprland.homeManagerModules.default ];
|
2022-11-26 16:02:02 +01:00
|
|
|
|
2022-11-25 10:24:29 +01:00
|
|
|
wayland.windowManager.hyprland = {
|
|
|
|
enable = true;
|
|
|
|
package = hyprland;
|
2023-04-30 18:35:46 +02:00
|
|
|
recommendedEnvironment = true;
|
2022-11-26 16:02:02 +01:00
|
|
|
extraConfig = import ./config.nix args;
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
2023-01-07 17:06:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# 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;
|
2022-11-26 16:02:02 +01:00
|
|
|
|
2023-01-07 17:06:29 +01:00
|
|
|
# start using systemd service
|
|
|
|
systemd = {
|
2022-11-26 16:02:02 +01:00
|
|
|
enable = true;
|
2023-04-30 18:35:46 +02:00
|
|
|
target = "graphical-session.target";
|
2022-11-26 16:02:02 +01:00
|
|
|
};
|
2023-01-07 17:06:29 +01:00
|
|
|
|
|
|
|
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";
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-12-23 12:39:24 +01:00
|
|
|
};
|
2022-11-26 16:02:02 +01:00
|
|
|
|
|
|
|
|
2023-01-07 17:06:29 +01:00
|
|
|
# lock screen after timeout
|
2023-01-07 17:07:02 +01:00
|
|
|
home-manager.users.moritz = {
|
2022-11-26 16:02:02 +01:00
|
|
|
services.swayidle = {
|
|
|
|
enable = true;
|
|
|
|
events = [
|
|
|
|
{
|
|
|
|
event = "before-sleep";
|
2023-04-30 18:35:46 +02:00
|
|
|
command = "${pkgs.swaylock}/bin/swaylock -fF";
|
2022-11-26 16:02:02 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
event = "lock";
|
2023-04-30 18:35:46 +02:00
|
|
|
command = "${pkgs.swaylock}/bin/swaylock -fF";
|
2022-11-26 16:02:02 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
];
|
2023-04-30 18:35:46 +02:00
|
|
|
systemdTarget = "hyprland-session.target";
|
2022-11-26 16:02:02 +01: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 = { };
|
|
|
|
|
|
|
|
|
|
|
|
# start hyprpaper daemon using systemd unit (to set wallpaper)
|
2023-04-30 18:35:46 +02:00
|
|
|
systemd.user.services.hyprpaper =
|
|
|
|
let
|
|
|
|
wallpaper = "/home/moritz/.config/wallpapers/a_short_walk.png";
|
|
|
|
config = pkgs.writeTextFile {
|
|
|
|
name = "hyprpaper.conf";
|
|
|
|
text = ''
|
2023-01-07 17:06:29 +01:00
|
|
|
preload = ${wallpaper}
|
|
|
|
wallpaper = ,${wallpaper}
|
|
|
|
'';
|
2023-04-30 18:35:46 +02:00
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
enable = true;
|
|
|
|
partOf = [ "graphical-session.target" ];
|
|
|
|
wantedBy = [ "graphical-session.target" ];
|
|
|
|
after = [ "graphical-session.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper -c ${config}";
|
|
|
|
RestartSec = "1s";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
2022-11-26 16:02:02 +01:00
|
|
|
|
2023-01-07 17:06:29 +01:00
|
|
|
# only consider graphical-session.target started when hyprland-sesstion.target is reached
|
|
|
|
systemd.user.targets.hyprland-session = {
|
|
|
|
wantedBy = [ "graphical-session.target" ];
|
2023-01-11 10:38:18 +01:00
|
|
|
before = [ "graphical-session.target" ];
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
2022-11-26 16:02:02 +01:00
|
|
|
|
2023-04-30 18:35:46 +02:00
|
|
|
systemd.user.services.xdg-desktop-portal-hyprland = {
|
|
|
|
after = [ "hyprland-session.target" ];
|
|
|
|
wantedBy = [ "hyprland-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
home-manager.users.moritz.systemd.user.services.nextcloud-client = {
|
|
|
|
Service = {
|
|
|
|
RestartSec = "1s";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
2023-01-07 17:06:29 +01:00
|
|
|
|
|
|
|
# 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-11-26 16:02:02 +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;
|
|
|
|
};
|
|
|
|
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";
|
2023-01-07 17:06:29 +01:00
|
|
|
sessionPackages = [ hyprland ]; # can't set the defaultSession otherwise
|
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
|
|
|
|
2023-01-07 17:06:29 +01:00
|
|
|
|
|
|
|
# dekstop portal (for screensharing)
|
2022-11-25 10:24:29 +01:00
|
|
|
xdg.portal = {
|
|
|
|
enable = true;
|
2023-04-30 18:35:46 +02:00
|
|
|
wlr.enable = mkForce false;
|
2022-12-30 19:01:31 +01:00
|
|
|
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
|
2022-11-25 10:24:29 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|