temporarily return home-manger, working hyprland module

This commit is contained in:
Charlie Root 2024-11-04 12:35:21 +01:00
commit fbb93a59d4
Signed by: faukah
SSH key fingerprint: SHA256:jpYIt4Vkz1NBTQcks/N9OPTfTFxE6KF2W/rV7hrfrIw
10 changed files with 406 additions and 200 deletions

23
flake.lock generated
View file

@ -279,6 +279,26 @@
} }
}, },
"home-manager": { "home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1730633670,
"narHash": "sha256-ZFJqIXpvVKvzOVFKWNRDyIyAo+GYdmEPaYi1bZB6uf0=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "8f6ca7855d409aeebe2a582c6fd6b6a8d0bf5661",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"home-manager_2": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"schizofox", "schizofox",
@ -729,6 +749,7 @@
"root": { "root": {
"inputs": { "inputs": {
"helix": "helix", "helix": "helix",
"home-manager": "home-manager",
"hyprland": "hyprland", "hyprland": "hyprland",
"hyprland-plugins": "hyprland-plugins", "hyprland-plugins": "hyprland-plugins",
"hyprsplit": "hyprsplit", "hyprsplit": "hyprsplit",
@ -766,7 +787,7 @@
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_2",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager_2",
"nixpak": "nixpak", "nixpak": "nixpak",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"

View file

@ -30,6 +30,10 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# Hyprland, my main compositor # Hyprland, my main compositor
hyprland.url = "github:hyprwm/Hyprland"; hyprland.url = "github:hyprwm/Hyprland";

View file

@ -1,6 +1,6 @@
_: { _: {
imports = [ imports = [
# ./home-manager.nix ./home-manager.nix
./system.nix ./system.nix
./xdg.nix ./xdg.nix
./git.nix ./git.nix

View file

@ -4,10 +4,9 @@
... ...
}: let }: let
cfg = config.modules.usrEnv.desktops.hyprland; cfg = config.modules.usrEnv.desktops.hyprland;
inherit (config.modules.other.system) username;
inherit (builtins) map genList toString; inherit (builtins) map genList toString;
in { in {
home-manager.users.${username}.wayland.windowManager.hyprland.settings = { programs.hyprland.settings = {
# Keybinds # Keybinds
bind = bind =
# workspaces # workspaces

View file

@ -1,70 +1,68 @@
{config, ...}: let {config, ...}: let
inherit (config.modules.other.system) username; inherit (config.modules.other.system) username;
in { in {
home-manager.users.${username} = { programs.hyprland.settings = {
wayland.windowManager.hyprland.settings = { #Decoration settings
#Decoration settings decoration = {
decoration = { rounding = 0;
rounding = 0; blur = {
blur = { enabled = true;
enabled = true; size = 3;
size = 3; passes = 2;
passes = 2;
};
drop_shadow = 1;
shadow_range = 15;
shadow_render_power = 2;
shadow_ignore_window = 1;
shadow_offset = "2 4";
shadow_scale = 1;
}; };
# Bezier curves for aninmations. drop_shadow = 1;
# Generate your own at https://www.cssportal.com/css-cubic-bezier-generator/ shadow_range = 15;
bezier = [ shadow_render_power = 2;
"dupa, 0.1, 0.9, 0.1, 1.05" shadow_ignore_window = 1;
]; shadow_offset = "2 4";
# Hyprland anomations, using the above bezier curves shadow_scale = 1;
animations = { };
enabled = false; # Bezier curves for aninmations.
animation = [ # Generate your own at https://www.cssportal.com/css-cubic-bezier-generator/
"windows, 1, 4, dupa, popin" bezier = [
"windowsOut, 1, 4, dupa, slide" "dupa, 0.1, 0.9, 0.1, 1.05"
"border, 1, 15, default" ];
"fade, 1, 10, default" # Hyprland anomations, using the above bezier curves
"workspaces, 1, 5, dupa, slidevert" animations = {
]; enabled = false;
}; animation = [
"windows, 1, 4, dupa, popin"
cursor = { "windowsOut, 1, 4, dupa, slide"
hide_on_key_press = true; "border, 1, 15, default"
no_hardware_cursors = true; "fade, 1, 10, default"
}; "workspaces, 1, 5, dupa, slidevert"
misc = {
enable_swallow = true;
swallow_regex = "foot";
focus_on_activate = true;
vrr = 1;
vfr = true;
animate_manual_resizes = false;
animate_mouse_windowdragging = false;
force_default_wallpaper = 0;
};
# Window rules for some programs.
windowrulev2 = [
"float, class:^(Tor Browser)$"
"float, class:^(mpv)$"
"float, class:^(imv)$"
"float, title:^(Picture-in-Picture)$"
"float, title:^(.*)(Choose User Profile)(.*)$"
"float, title:^(blob:null/)(.*)$"
"float, class:^(xdg-desktop-portal-gtk)$"
"float, class:^(code), title: ^(Open*)"
"size 70% 70%, class:^(code), title: ^(Open*)"
"center, class: ^(code), title: ^(Open*)"
"float, class:^(org.keepassxc.KeePassXC)$"
]; ];
}; };
cursor = {
hide_on_key_press = true;
no_hardware_cursors = true;
};
misc = {
enable_swallow = true;
swallow_regex = "foot";
focus_on_activate = true;
vrr = 1;
vfr = true;
animate_manual_resizes = false;
animate_mouse_windowdragging = false;
force_default_wallpaper = 0;
};
# Window rules for some programs.
windowrulev2 = [
"float, class:^(Tor Browser)$"
"float, class:^(mpv)$"
"float, class:^(imv)$"
"float, title:^(Picture-in-Picture)$"
"float, title:^(.*)(Choose User Profile)(.*)$"
"float, title:^(blob:null/)(.*)$"
"float, class:^(xdg-desktop-portal-gtk)$"
"float, class:^(code), title: ^(Open*)"
"size 70% 70%, class:^(code), title: ^(Open*)"
"center, class: ^(code), title: ^(Open*)"
"float, class:^(org.keepassxc.KeePassXC)$"
];
}; };
} }

View file

@ -3,32 +3,29 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (config.modules.other.system) username;
inherit (config.modules.style) cursor; inherit (config.modules.style) cursor;
inherit (builtins) toString; inherit (builtins) toString;
in { in {
home-manager.users.${username} = { programs.hyprland.settings = {
wayland.windowManager.hyprland.settings = { # Hyprland settings
# Hyprland settings # Programs which get executed at Hyprland start.
# Programs which get executed at Hyprland start. exec-once = [
exec-once = [ "hyprctl setcursor ${cursor.name} ${toString cursor.size}"
"hyprctl setcursor ${cursor.name} ${toString cursor.size}" #start waybar
#start waybar "${pkgs.waybar}/bin/waybar"
"${pkgs.waybar}/bin/waybar" # "${pkgs.ianny}/bin/ianny"
# "${pkgs.ianny}/bin/ianny"
# run persistent special workspace windows # run persistent special workspace windows
# "[workspace special:nixos; silent;tile] ${pkgs.foot}/bin/foot -D ~/projects/nichts" # "[workspace special:nixos; silent;tile] ${pkgs.foot}/bin/foot -D ~/projects/nichts"
"[workspace special:keepassxc; silent;tile] ${pkgs.keepassxc}/bin/keepassxc" "[workspace special:keepassxc; silent;tile] ${pkgs.keepassxc}/bin/keepassxc"
"[workspace special:audio; silent;tile] ${pkgs.pwvucontrol}/bin/pwvucontrol" "[workspace special:audio; silent;tile] ${pkgs.pwvucontrol}/bin/pwvucontrol"
"${pkgs.swww}/bin/swww-daemon" "${pkgs.swww}/bin/swww-daemon"
"${pkgs.wlsunset}/bin/wlsunset -S 06:00 -s 20:00" "${pkgs.wlsunset}/bin/wlsunset -S 06:00 -s 20:00"
"${pkgs.lxqt.lxqt-policykit}/bin/lxqt-policykit-agent" "${pkgs.lxqt.lxqt-policykit}/bin/lxqt-policykit-agent"
"hyprctl dispatch split:workspace 1" "hyprctl dispatch split:workspace 1"
]; ];
};
}; };
} }

View file

@ -5,7 +5,6 @@
... ...
}: let }: let
cfg = config.modules.usrEnv.desktops.hyprland; cfg = config.modules.usrEnv.desktops.hyprland;
inherit (config.meta.mainUser) username;
# inherit (inputs.hyprsplit.packages.${pkgs.system}) hyprsplit; # inherit (inputs.hyprsplit.packages.${pkgs.system}) hyprsplit;
inherit (lib) mkIf mkDefault; inherit (lib) mkIf mkDefault;
in { in {
@ -15,6 +14,7 @@ in {
./exec.nix ./exec.nix
./settings.nix ./settings.nix
./workspaces.nix ./workspaces.nix
./nixos-module.nix
]; ];
# we disable the default hyprland module # we disable the default hyprland module
disabledModules = ["programs/hyprland.nix"]; disabledModules = ["programs/hyprland.nix"];
@ -22,8 +22,13 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.hyprland = { programs.hyprland = {
enable = true; enable = true;
xwayland.enable = true;
package = pkgs.hyprland; package = pkgs.hyprland;
portalPackage = pkgs.xdg-desktop-portal-hyprland; portalPackage = pkgs.xdg-desktop-portal-hyprland;
plugins = [
pkgs.hyprlandPlugins.hyprsplit
# pkgs.hyprlandPlugins.hypr-dynamic-cursors
];
}; };
# xdg Portal # xdg Portal
xdg.portal = { xdg.portal = {
@ -39,26 +44,5 @@ in {
common.default = ["gtk" "hyprland"]; common.default = ["gtk" "hyprland"];
}; };
}; };
home-manager.users.${username} = {
wayland.windowManager.hyprland = {
enable = true;
package = pkgs.hyprland;
# Split-monitor-workspaces provides awesome-like workspace behaviour
plugins = [
pkgs.hyprlandPlugins.hyprsplit
pkgs.hyprlandPlugins.hypr-dynamic-cursors
];
# Xwayland for X applications
xwayland.enable = true;
# No idea why I set this
systemd = {
enable = true;
variables = ["--all"];
};
};
};
}; };
} }

View file

@ -0,0 +1,204 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.programs.hyprland;
toHyprconf = {
attrs,
indentLevel ? 0,
importantPrefixes ? ["$"],
}: let
inherit
(lib)
all
concatMapStringsSep
concatStrings
concatStringsSep
filterAttrs
foldl
generators
hasPrefix
isAttrs
isList
mapAttrsToList
replicate
;
initialIndent = concatStrings (replicate indentLevel " ");
toHyprconf' = indent: attrs: let
sections =
filterAttrs (n: v: isAttrs v || (isList v && all isAttrs v)) attrs;
mkSection = n: attrs:
if lib.isList attrs
then (concatMapStringsSep "\n" (a: mkSection n a) attrs)
else ''
${indent}${n} {
${toHyprconf' " ${indent}" attrs}${indent}}
'';
mkFields = generators.toKeyValue {
listsAsDuplicateKeys = true;
inherit indent;
};
allFields =
filterAttrs (n: v: !(isAttrs v || (isList v && all isAttrs v)))
attrs;
isImportantField = n: _:
foldl (acc: prev:
if hasPrefix prev n
then true
else acc)
false
importantPrefixes;
importantFields = filterAttrs isImportantField allFields;
fields =
builtins.removeAttrs allFields
(mapAttrsToList (n: _: n) importantFields);
in
mkFields importantFields
+ concatStringsSep "\n" (mapAttrsToList mkSection sections)
+ mkFields fields;
in
toHyprconf' initialIndent attrs;
in {
options.programs.hyprland = {
plugins = lib.mkOption {
type = with lib.types; listOf (either package path);
default = [];
description = ''
List of Hyprland plugins to use. Can either be packages or
absolute plugin paths.
'';
};
settings = lib.mkOption {
type = with lib.types; let
valueType =
nullOr (oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
])
// {
description = "Hyprland configuration value";
};
in
valueType;
default = {};
description = ''
Hyprland configuration written in Nix. Entries with the same key
should be written as lists. Variables' and colors' names should be
quoted. See <https://wiki.hyprland.org> for more examples.
::: {.note}
Use the [](#opt-wayland.windowManager.hyprland.plugins) option to
declare plugins.
:::
'';
example = lib.literalExpression ''
{
decoration = {
shadow_offset = "0 5";
"col.shadow" = "rgba(00000099)";
};
"$mod" = "SUPER";
bindm = [
# mouse movements
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
"$mod ALT, mouse:272, resizewindow"
];
}
'';
};
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
example = ''
# window resize
bind = $mod, S, submap, resize
submap = resize
binde = , right, resizeactive, 10 0
binde = , left, resizeactive, -10 0
binde = , up, resizeactive, 0 -10
binde = , down, resizeactive, 0 10
bind = , escape, submap, reset
submap = reset
'';
description = ''
Extra configuration lines to add to `~/.config/hypr/hyprland.conf`.
'';
};
sourceFirst =
lib.mkEnableOption ''
putting source entries at the top of the configuration
''
// {
default = true;
};
importantPrefixes = lib.mkOption {
type = with lib.types; listOf str;
default =
["$" "bezier" "name"]
++ lib.optionals cfg.sourceFirst ["source"];
example = ["$" "bezier"];
description = ''
List of prefix of attributes to source at the top of the config.
'';
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = lib.concatLists [
(lib.optional (cfg.package != null) cfg.package)
(lib.optional (cfg.xwayland.enable) pkgs.xwayland)
];
environment.etc."xdg/hypr/hyprland.conf" = let
shouldGenerate = cfg.extraConfig != "" || cfg.settings != {} || cfg.plugins != [];
pluginsToHyprconf = plugins:
toHyprconf {
attrs = {
plugin = let
mkEntry = entry:
if lib.types.package.check entry
then "${entry}/lib/lib${entry.pname}.so"
else entry;
in
map mkEntry cfg.plugins;
};
inherit (cfg) importantPrefixes;
};
in
lib.mkIf shouldGenerate {
text =
lib.optionalString (cfg.plugins != [])
(pluginsToHyprconf cfg.plugins)
+ lib.optionalString (cfg.settings != {})
(toHyprconf {
attrs = cfg.settings;
inherit (cfg) importantPrefixes;
})
+ lib.optionalString (cfg.extraConfig != "") cfg.extraConfig;
};
};
}

View file

@ -9,68 +9,70 @@
inherit (builtins) toString; inherit (builtins) toString;
inherit (config.modules.style.colorScheme) colors; inherit (config.modules.style.colorScheme) colors;
in { in {
home-manager.users.${username} = { config = {
wayland.windowManager.hyprland.settings = { programs.hyprland = {
# Hyprland settings settings = {
"$mainMod" = "SUPER"; # Hyprland settings
"$mainMod" = "SUPER";
# Monitor config # Monitor config
# Thanks Poz for inspiration, using an attrSet is actually much smarter # Thanks Poz for inspiration, using an attrSet is actually much smarter
# than using a normal list. # than using a normal list.
monitor = monitor =
mapAttrsToList ( mapAttrsToList (
name: m: let name: m: let
w = toString m.resolution.x; w = toString m.resolution.x;
h = toString m.resolution.y; h = toString m.resolution.y;
refreshRate = toString m.refreshRate; refreshRate = toString m.refreshRate;
x = toString m.position.x; x = toString m.position.x;
y = toString m.position.y; y = toString m.position.y;
scale = toString m.scale; scale = toString m.scale;
in "${name},${w}x${h}@${refreshRate},${x}x${y},${scale}" in "${name},${w}x${h}@${refreshRate},${x}x${y},${scale}"
) )
monitors; monitors;
# Input settings # Input settings
input = { input = {
kb_layout = "de,ru, us"; kb_layout = "de,ru, us";
kb_variant = ",phonetic_winkeys,dvorak"; kb_variant = ",phonetic_winkeys,dvorak";
kb_options = "grp:rctrl_rshift_toggle, caps:escape"; kb_options = "grp:rctrl_rshift_toggle, caps:escape";
follow_mouse = true; follow_mouse = true;
repeat_rate = 60; repeat_rate = 60;
repeat_delay = 200; repeat_delay = 200;
touchpad = { touchpad = {
disable_while_typing = true; disable_while_typing = true;
}; };
}; };
general = { general = {
layout = "dwindle"; layout = "dwindle";
gaps_in = 0; gaps_in = 0;
gaps_out = 0; gaps_out = 0;
border_size = 2; border_size = 2;
"col.active_border" = "0xff${colors.base07}"; "col.active_border" = "0xff${colors.base07}";
no_border_on_floating = true; no_border_on_floating = true;
}; };
plugin = { plugin = {
hyprsplit = { hyprsplit = {
num_workspaces = 10; num_workspaces = 10;
persistent_workspaces = true; persistent_workspaces = true;
}; };
dynamic-cursors = { dynamic-cursors = {
enabled = true; enabled = true;
mode = "rotate"; mode = "rotate";
rotate = { rotate = {
length = 20; length = 20;
offset = 0.0; offset = 0.0;
};
threshhold = 2;
shake.enabled = false;
}; };
threshhold = 2;
shake.enabled = false;
}; };
}; };
}; };

View file

@ -3,45 +3,42 @@
lib, lib,
... ...
}: let }: let
inherit (config.meta.mainUser) username;
inherit (config.modules.system.hardware) monitors; inherit (config.modules.system.hardware) monitors;
inherit (lib) imap0 flatten optionalString; inherit (lib) imap0 flatten optionalString;
inherit (builtins) map genList attrNames toString; inherit (builtins) map genList attrNames toString;
in { in {
home-manager.users.${username} = { programs.hyprland.settings = {
wayland.windowManager.hyprland.settings = { # INFO: This is a custom function to map all of my monitors to workspaces.
# INFO: This is a custom function to map all of my monitors to workspaces. # Since I use split-monitor-workspaces, I map 10 workspaces to each monitor
# Since I use split-monitor-workspaces, I map 10 workspaces to each monitor # and set the first one to be the default one.
# and set the first one to be the default one. # To be able to use this for a varying amount of monitors we do some nasty trickery.
# To be able to use this for a varying amount of monitors we do some nasty trickery. # This was inspired by jacekpoz, whose configuration is linked in this project's README.md.
# This was inspired by jacekpoz, whose configuration is linked in this project's README.md. workspace =
workspace = # We're creating several lists of workspace assignments, one for each monitor,
# We're creating several lists of workspace assignments, one for each monitor, # and have to merge them into one big list.
# and have to merge them into one big list. (flatten
(flatten # We then use imap0 insted of map because imap0 starts indexing at zero as oppsed to one with map.
# We then use imap0 insted of map because imap0 starts indexing at zero as oppsed to one with map. (imap0 (monitorIndex: monitorName: (
(imap0 (monitorIndex: monitorName: ( map (
map ( i: let
i: let # we define our own modulo operation for this,
# we define our own modulo operation for this, # since only the first workspace on each monitor is the default workspace.
# since only the first workspace on each monitor is the default workspace. mod = a: b: a - (b * (a / b));
mod = a: b: a - (b * (a / b)); workspace = toString i;
workspace = toString i; isDefault = (mod i 10) == 1; # 11, 21, 31, ...
isDefault = (mod i 10) == 1; # 11, 21, 31, ... in "${workspace}, monitor:${monitorName}${optionalString isDefault ", default:true"}"
in "${workspace}, monitor:${monitorName}${optionalString isDefault ", default:true"}" )
) # we generate a list of 10 elements for each monitor. We have to add 1 each time since genList starts indexing at 0.
# we generate a list of 10 elements for each monitor. We have to add 1 each time since genList starts indexing at 0. # also, we add the monitorIndex * 10 to get 10 workspaces for each individual monitor.
# also, we add the monitorIndex * 10 to get 10 workspaces for each individual monitor. (genList (i: i + 1 + (10 * monitorIndex)) 10)
(genList (i: i + 1 + (10 * monitorIndex)) 10) ))
)) # our attrSet of different monitors
# our attrSet of different monitors (attrNames monitors)))
(attrNames monitors))) # These are my two special workspaces
# These are my two special workspaces ++ [
++ [ "special:nixos, decorate:false"
"special:nixos, decorate:false" "special:keepassxc, decorate:false"
"special:keepassxc, decorate:false" "special:audio, decorate:false"
"special:audio, decorate:false" ];
];
};
}; };
} }