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,8 +1,7 @@
{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;
@ -66,5 +65,4 @@ in {
"float, class:^(org.keepassxc.KeePassXC)$" "float, class:^(org.keepassxc.KeePassXC)$"
]; ];
}; };
};
} }

View file

@ -3,12 +3,10 @@
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 = [
@ -30,5 +28,4 @@ in {
"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,8 +9,9 @@
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 = {
settings = {
# Hyprland settings # Hyprland settings
"$mainMod" = "SUPER"; "$mainMod" = "SUPER";
@ -75,4 +76,5 @@ in {
}; };
}; };
}; };
};
} }

View file

@ -3,13 +3,11 @@
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.
@ -43,5 +41,4 @@ in {
"special:audio, decorate:false" "special:audio, decorate:false"
]; ];
}; };
};
} }