nix-config/modules/wm/hyprland/default.nix

135 lines
4.5 KiB
Nix

{
inputs,
outputs,
lib,
config,
pkgs,
...
}: let
inherit (lib) mkIf trivial strings replaceStrings;
cfg = config.horseman.wm.hyprland;
in {
imports = [
./options.nix
];
config = mkIf cfg.enable {
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
security.polkit.enable = true;
environment.systemPackages = with pkgs; [
brightnessctl
eww
fortune
hypridle
hyprlock
hyprpaper
hyprpolkitagent
hyprshot
jq
networkmanagerapplet
playerctl
pulsemixer
python312Packages.gpustat
swaynotificationcenter
wirelesstools
wl-clipboard
wofi
xdg-desktop-portal-hyprland
];
services.logind.extraConfig = ''
HandlePowerKey=ignore
'';
system.activationScripts.script.text = ''
cd /home/horseman/.config
rm -r hypr/*
touch hypr/hyprland.conf
printf "# This file has been auto-generated.
${builtins.concatStringsSep "\n" (map (x: "exec-once = " + x) cfg.config.execOnce)}
${builtins.concatStringsSep "\n" (map (x: "env = " + x) cfg.config.env)}
general {
gaps_in = ${toString cfg.config.general.gapsIn}
gaps_out = ${toString cfg.config.general.gapsOut}
border_size = ${toString cfg.config.general.borderSize}
col.active_border = ${cfg.config.general.col.activeBorder}
col.inactive_border = ${cfg.config.general.col.inactiveBorder}
resize_on_border = ${trivial.boolToString cfg.config.general.resizeOnBorder}
allow_tearing = ${trivial.boolToString cfg.config.general.allowTearing}
layout = ${cfg.config.general.layout}
}
decoration {
rounding = ${toString cfg.config.decoration.rounding}
active_opacity = ${strings.floatToString cfg.config.decoration.activeOpacity}
inactive_opacity = ${strings.floatToString cfg.config.decoration.inactiveOpacity}
shadow {
enabled = ${trivial.boolToString cfg.config.decoration.shadow.enabled}
range = ${toString cfg.config.decoration.shadow.range}
render_power = ${toString cfg.config.decoration.shadow.renderPower}
color = ${cfg.config.decoration.shadow.color}
}
blur {
enabled = ${trivial.boolToString cfg.config.decoration.blur.enabled}
size = ${toString cfg.config.decoration.blur.size}
passes = ${toString cfg.config.decoration.blur.passes}
vibrancy = ${strings.floatToString cfg.config.decoration.blur.vibrancy}
}
}
animations {
enabled = ${trivial.boolToString cfg.config.animations.enabled}
${builtins.concatStringsSep "\n " (map(bez: "bezier = ${bez.name}, ${strings.floatToString bez.startX}, ${strings.floatToString bez.startY}, ${strings.floatToString bez.endX}, ${strings.floatToString bez.endY}") cfg.config.animations.beziers)}
${builtins.concatStringsSep "\n " (map(anim: "animation = ${anim.name}, ${toString anim.on}, ${strings.floatToString anim.speed}, ${anim.curve}, ${replaceStrings ["%"] ["%%"] anim.style}") cfg.config.animations.animations)}
}
dwindle {
pseudotile = ${trivial.boolToString cfg.config.dwindle.pseudotile}
preserve_split = ${trivial.boolToString cfg.config.dwindle.preserveSplit}
}
master {
new_status = ${cfg.config.master.newStatus}
}
misc {
force_default_wallpaper = ${toString cfg.config.misc.forceDefaultWallpaper}
}
input {
kb_layout = ${cfg.config.input.kbLayout}
repeat_rate = ${toString cfg.config.input.repeatRate}
repeat_delay = ${toString cfg.config.input.repeatDelay}
follow_mouse = ${toString cfg.config.input.followMouse}
sensitivity = ${strings.floatToString cfg.config.input.sensitivity}
numlock_by_default = ${trivial.boolToString cfg.config.input.numlockByDefault}
touchpad {
natural_scroll = ${trivial.boolToString cfg.config.input.touchpad.naturalScroll}
}
}
gestures {
workspace_swipe = ${trivial.boolToString cfg.config.gestures.workspaceSwipe}
}
${builtins.concatStringsSep "\n" (map (ws: "workspace = " + ws) cfg.config.workspaces)}
${builtins.concatStringsSep "\n" (map (wr: "windowrule = " + replaceStrings ["%"] ["%%"] wr) cfg.config.windowrules)}
" >> hypr/hyprland.conf
'';
};
}