restructure so the options don't have the config already mixed in

This commit is contained in:
KoenDR06 2025-07-16 14:45:59 +02:00
parent 2c5692e76b
commit 26b9dbf83c
2 changed files with 389 additions and 382 deletions

View file

@ -1,19 +1,17 @@
{ {
inputs,
outputs,
lib, lib,
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkIf trivial strings replaceStrings; inherit (lib) mkIf;
cfg = config.horseman.wm.hyprland; cfg123 = config.horseman.wm.hyprland;
in { in {
imports = [ imports = [
./options.nix ./options.nix
]; ];
config = mkIf cfg.enable { config = mkIf cfg123.enable {
programs.hyprland = { programs.hyprland = {
enable = true; enable = true;
xwayland.enable = true; xwayland.enable = true;
@ -41,99 +39,250 @@ in {
xdg-desktop-portal-hyprland xdg-desktop-portal-hyprland
]; ];
horseman.wm.hyprland.config = {
execOnce = [
"hyprpaper"
"eww daemon"
"hypridle"
"hyprpaper"
"swaync"
];
env = [
"XCURSOR_SIZE,24"
"HYPRCURSOR_SIZE,24"
];
windowrules = [
"suppressevent maximize, class:.*"
"nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0"
"rounding 0, floating:0 onworkspace:w[t1]"
"bordersize 0, floating:0 onworkspace:w[t1]"
"float, initialTitle:^Picture-in-Picture$"
"center, initialTitle:^Picture-in-Picture$"
"size 33% 33%, initialTitle:^Picture-in-Picture$"
"float, initialClass:CImg"
];
workspaces = [
"w[t1], gapsout:0, gapsin:0"
];
general = {
gapsIn = 5;
gapsOut = 5;
borderSize = 2;
resizeOnBorder = true;
allowTearing = false;
col.activeBorder = "rgba(b7bdf8ff)";
col.inactiveBorder = "rgba(b7bdf840)";
layout = "dwindle";
};
decoration = {
rounding = 10;
activeOpacity = 1.0;
inactiveOpacity = 1.0;
shadow = {
enabled = true;
range = 4;
renderPower = 3;
color = "rgba(1a1a1aee)";
};
blur = {
enabled = true;
size = 3;
passes = 3;
vibrancy = 0.1696;
};
};
animations = {
enabled = true;
beziers = [
{
name = "easeOutQuint";
startX = 0.23;
startY = 1.0;
endX = 0.32;
endY = 1.0;
}
{
name = "easeInOutCubic";
startX = 0.65;
startY = 0.05;
endX = 0.36;
endY = 1.0;
}
{
name = "linear";
startX = 0.0;
startY = 0.0;
endX = 1.0;
endY = 1.0;
}
{
name = "almostLinear";
startX = 0.5;
startY = 0.5;
endX = 0.75;
endY = 1.0;
}
{
name = "quick";
startX = 0.15;
startY = 0.0;
endX = 0.1;
endY = 1.0;
}
];
animations = [
{
name = "global";
on = true;
speed = 10.0;
curve = "default";
}
{
name = "border";
on = true;
speed = 5.39;
curve = "easeOutQuint";
}
{
name = "windows";
on = true;
speed = 4.79;
curve = "easeOutQuint";
}
{
name = "windowsIn";
on = true;
speed = 4.1;
curve = "easeOutQuint";
style = "popin 87%";
}
{
name = "windowsOut";
on = true;
speed = 1.49;
curve = "linear";
style = "popin 87%";
}
{
name = "fadeIn";
on = true;
speed = 1.73;
curve = "almostLinear";
}
{
name = "fadeOut";
on = true;
speed = 1.46;
curve = "almostLinear";
}
{
name = "fade";
on = true;
speed = 3.03;
curve = "quick";
}
{
name = "layers";
on = true;
speed = 3.81;
curve = "easeOutQuint";
}
{
name = "layersIn";
on = true;
speed = 4.0;
curve = "easeOutQuint";
style = "fade";
}
{
name = "layersOut";
on = true;
speed = 1.5;
curve = "linear";
style = "fade";
}
{
name = "fadeLayersIn";
on = true;
speed = 1.79;
curve = "almostLinear";
}
{
name = "fadeLayersOut";
on = true;
speed = 1.39;
curve = "almostLinear";
}
{
name = "workspaces";
on = true;
speed = 1.94;
curve = "almostLinear";
style = "fade";
}
{
name = "workspacesIn";
on = true;
speed = 1.21;
curve = "almostLinear";
style = "fade";
}
{
name = "workspacesOut";
on = true;
speed = 1.94;
curve = "almostLinear";
style = "fade";
}
];
};
dwindle = {
pseudotile = true;
preserveSplit = true;
};
master = {
newStatus = "master";
};
misc = {
forceDefaultWallpaper = 0;
};
input = {
kbLayout = "us";
repeatRate = 50;
repeatDelay = 300;
followMouse = 1;
sensitivity = 0.0;
touchpad.naturalScroll = true;
numlockByDefault = true;
};
gestures = {
workspaceSwipe = false;
};
monitors = {
defaultMonitor = true;
};
};
services.logind.extraConfig = '' services.logind.extraConfig = ''
HandlePowerKey=ignore 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 (mon: "monitor = ${mon.output}, ${mon.resolution}@${mon.refreshRate}, ${toString mon.x}x${toString mon.y}, ${strings.floatToString mon.scale}, transform, ${toString mon.transform}") cfg.config.monitors.displays)}
${if cfg.config.monitors.defaultMonitor then "monitor = ,preferred, auto, auto" else ""}
${builtins.concatStringsSep "\n" (map (ws: "workspace = " + ws) cfg.config.workspaces)}
${builtins.concatStringsSep "\n" (map (wr: "windowrule = " + replaceStrings ["%"] ["%%"] wr) cfg.config.windowrules)}
" >> hypr/hyprland.conf
'';
}; };
} }

View file

@ -1,162 +1,82 @@
{ {
lib, lib,
config,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption types; inherit (lib) mkEnableOption mkOption types trivial strings replaceStrings;
cfg = config.horseman.wm.hyprland;
keybinding = types.submodule {
options = {
flags = mkOption {
type = types.listOf types.enum [ "l" "r" "c" "g" "o" "e" "m" "t" "i" "s" "d" "p" ];
default = [];
};
mods = mkOption {
type = types.listOf types.str;
};
key = mkOption {
type = types.str;
};
dispatcher = mkOption {
type = types.str;
};
params = mkOption {
type = types.str;
};
};
};
in { in {
options = { options = {
horseman.wm.hyprland = { horseman.wm.hyprland = {
enable = mkEnableOption "Hyprland"; enable = mkEnableOption "Hyprland";
config = { config = {
execOnce = mkOption { execOnce = mkOption { type = types.listOf types.str; };
type = types.listOf types.str; env = mkOption { type = types.listOf types.str; };
default = [ windowrules = mkOption { type = types.listOf types.str; };
"hyprpaper"
"eww daemon"
"hypridle"
"hyprpaper"
"swaync"
];
};
env = mkOption {
type = types.listOf types.str;
default = [
"XCURSOR_SIZE,24"
"HYPRCURSOR_SIZE,24"
];
};
windowrules = mkOption {
type = types.listOf types.str;
default = [
"suppressevent maximize, class:.*"
"nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0"
"rounding 0, floating:0 onworkspace:w[t1]"
"bordersize 0, floating:0 onworkspace:w[t1]"
"float, initialTitle:^Picture-in-Picture$"
"center, initialTitle:^Picture-in-Picture$"
"size 33% 33%, initialTitle:^Picture-in-Picture$"
"float, initialClass:CImg"
];
};
workspaces = mkOption { workspaces = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [
"w[t1], gapsout:0, gapsin:0"
];
}; };
general = { general = {
gapsIn = mkOption { gapsIn = mkOption { type = types.int; };
type = types.int; gapsOut = mkOption { type = types.int; };
default = 5; borderSize = mkOption { type = types.int; };
}; col.activeBorder = mkOption { type = types.str; };
col.inactiveBorder = mkOption { type = types.str; };
gapsOut = mkOption { resizeOnBorder = mkOption { type = types.bool; };
type = types.int; allowTearing = mkOption { type = types.bool; };
default = 5; layout = mkOption { type = types.enum ["dwindle" "master"]; };
};
borderSize = mkOption {
type = types.int;
default = 2;
};
col.activeBorder = mkOption {
type = types.str;
default = "rgba(b7bdf8ff)";
};
col.inactiveBorder = mkOption {
type = types.str;
default = "rgba(b7bdf840)";
};
resizeOnBorder = mkOption {
type = types.bool;
default = true;
};
allowTearing = mkOption {
type = types.bool;
default = false;
};
layout = mkOption {
type = types.enum ["dwindle" "master"];
default = "dwindle";
};
}; };
decoration = { decoration = {
rounding = mkOption { rounding = mkOption { type = types.int; };
type = types.int; activeOpacity = mkOption { type = types.float; };
default = 10; inactiveOpacity = mkOption { type = types.float; };
};
activeOpacity = mkOption {
type = types.float;
default = 1.0;
};
inactiveOpacity = mkOption {
type = types.float;
default = 1.0;
};
shadow = { shadow = {
enabled = mkOption { enabled = mkOption { type = types.bool; };
type = types.bool; range = mkOption { type = types.int; };
default = true; renderPower = mkOption { type = types.int; };
}; color = mkOption { type = types.str; };
range = mkOption {
type = types.int;
default = 4;
};
renderPower = mkOption {
type = types.int;
default = 3;
};
color = mkOption {
type = types.str;
default = "rgba(1a1a1aee)";
};
}; };
blur = { blur = {
enabled = mkOption { enabled = mkOption { type = types.bool; };
type = types.bool; size = mkOption { type = types.int; };
default = true; passes = mkOption { type = types.int; };
}; vibrancy = mkOption { type = types.float; };
size = mkOption {
type = types.int;
default = 3;
};
passes = mkOption {
type = types.int;
default = 3;
};
vibrancy = mkOption {
type = types.float;
default = 0.1696;
};
}; };
}; };
animations = { animations = {
enabled = mkOption { enabled = mkOption {
type = types.bool; type = types.bool;
default = true;
}; };
beziers = mkOption { beziers = mkOption {
@ -169,43 +89,6 @@ in {
endY = mkOption {type = types.number;}; endY = mkOption {type = types.number;};
}; };
}); });
default = [
{
name = "easeOutQuint";
startX = 0.23;
startY = 1.0;
endX = 0.32;
endY = 1.0;
}
{
name = "easeInOutCubic";
startX = 0.65;
startY = 0.05;
endX = 0.36;
endY = 1.0;
}
{
name = "linear";
startX = 0.0;
startY = 0.0;
endX = 1.0;
endY = 1.0;
}
{
name = "almostLinear";
startX = 0.5;
startY = 0.5;
endX = 0.75;
endY = 1.0;
}
{
name = "quick";
startX = 0.15;
startY = 0.0;
endX = 0.1;
endY = 1.0;
}
];
}; };
animations = mkOption { animations = mkOption {
@ -218,175 +101,59 @@ in {
style = mkOption {type = types.str; default = "";}; style = mkOption {type = types.str; default = "";};
}; };
}); });
default = [
{
name = "global";
on = true;
speed = 10.0;
curve = "default";
}
{
name = "border";
on = true;
speed = 5.39;
curve = "easeOutQuint";
}
{
name = "windows";
on = true;
speed = 4.79;
curve = "easeOutQuint";
}
{
name = "windowsIn";
on = true;
speed = 4.1;
curve = "easeOutQuint";
style = "popin 87%";
}
{
name = "windowsOut";
on = true;
speed = 1.49;
curve = "linear";
style = "popin 87%";
}
{
name = "fadeIn";
on = true;
speed = 1.73;
curve = "almostLinear";
}
{
name = "fadeOut";
on = true;
speed = 1.46;
curve = "almostLinear";
}
{
name = "fade";
on = true;
speed = 3.03;
curve = "quick";
}
{
name = "layers";
on = true;
speed = 3.81;
curve = "easeOutQuint";
}
{
name = "layersIn";
on = true;
speed = 4.0;
curve = "easeOutQuint";
style = "fade";
}
{
name = "layersOut";
on = true;
speed = 1.5;
curve = "linear";
style = "fade";
}
{
name = "fadeLayersIn";
on = true;
speed = 1.79;
curve = "almostLinear";
}
{
name = "fadeLayersOut";
on = true;
speed = 1.39;
curve = "almostLinear";
}
{
name = "workspaces";
on = true;
speed = 1.94;
curve = "almostLinear";
style = "fade";
}
{
name = "workspacesIn";
on = true;
speed = 1.21;
curve = "almostLinear";
style = "fade";
}
{
name = "workspacesOut";
on = true;
speed = 1.94;
curve = "almostLinear";
style = "fade";
}
];
}; };
}; };
dwindle = { dwindle = {
pseudotile = mkOption { pseudotile = mkOption {
type = types.bool; type = types.bool;
default = true;
}; };
preserveSplit = mkOption { preserveSplit = mkOption {
type = types.bool; type = types.bool;
default = true;
}; };
}; };
master = { master = {
newStatus = mkOption { newStatus = mkOption {
type = types.enum ["master" "slave" "inherit"]; type = types.enum ["master" "slave" "inherit"];
default = "master";
}; };
}; };
misc = { misc = {
forceDefaultWallpaper = mkOption { forceDefaultWallpaper = mkOption {
type = types.enum [ 0 1 2 (-1) ]; type = types.enum [ 0 1 2 (-1) ];
default = 0;
}; };
}; };
input = { input = {
kbLayout = mkOption { kbLayout = mkOption {
type = types.str; type = types.str;
default = "us";
}; };
repeatRate = mkOption { repeatRate = mkOption {
type = types.int; type = types.int;
default = 50;
}; };
repeatDelay = mkOption { repeatDelay = mkOption {
type = types.int; type = types.int;
default = 300;
}; };
followMouse = mkOption { followMouse = mkOption {
type = types.enum [ 0 1 2 3 ]; type = types.enum [ 0 1 2 3 ];
default = 1;
}; };
sensitivity = mkOption { sensitivity = mkOption {
type = types.numbers.between (-1.0) 1.0; type = types.numbers.between (-1.0) 1.0;
default = 0.0;
}; };
numlockByDefault = mkOption { numlockByDefault = mkOption {
type = types.bool; type = types.bool;
default = true;
}; };
touchpad = { touchpad = {
naturalScroll = mkOption { naturalScroll = mkOption {
type = types.bool; type = types.bool;
default = true;
}; };
}; };
}; };
@ -394,14 +161,12 @@ in {
gestures = { gestures = {
workspaceSwipe = mkOption { workspaceSwipe = mkOption {
type = types.bool; type = types.bool;
default = false;
}; };
}; };
monitors = { monitors = {
defaultMonitor = mkOption { defaultMonitor = mkOption {
type = types.bool; type = types.bool;
default = true;
}; };
displays = mkOption { displays = mkOption {
@ -419,10 +184,103 @@ in {
}; };
}; };
keybindings = { keybindings = mkOption {
type = types.listOf keybinding;
};
};
};
};
}; config = {
}; 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 (mon: "monitor = ${mon.output}, ${mon.resolution}@${mon.refreshRate}, ${toString mon.x}x${toString mon.y}, ${strings.floatToString mon.scale}, transform, ${toString mon.transform}") cfg.config.monitors.displays)}
${if cfg.config.monitors.defaultMonitor then "monitor = ,preferred, auto, auto" else ""}
${builtins.concatStringsSep "\n" (map (ws: "workspace = " + ws) cfg.config.workspaces)}
${builtins.concatStringsSep "\n" (map (wr: "windowrule = " + replaceStrings ["%"] ["%%"] wr) cfg.config.windowrules)}
" >> hypr/hyprland.conf
'';
}; };
} }