Skip to content

Commit 049dea2

Browse files
committed
feat(wrapperModules.hyprland): init
1 parent 6e7f66f commit 049dea2

2 files changed

Lines changed: 99 additions & 2 deletions

File tree

maintainers/default.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{ lib }:
2-
{
1+
{ lib }: {
32
inherit (lib.maintainers) birdee ameer;
43
patwid = {
54
name = "Patrick Widmer";
@@ -116,4 +115,9 @@
116115
github = "aliaslion";
117116
githubId = "122117018";
118117
};
118+
jonas-elhs = {
119+
name = "Jonas Elhs";
120+
github = "jonas-elhs";
121+
githubId = 177471339;
122+
};
119123
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
config,
3+
wlib,
4+
lib,
5+
pkgs,
6+
...
7+
}:
8+
let
9+
isLinkable = wlib.types.linkable.check;
10+
in
11+
{
12+
imports = [ wlib.modules.default ];
13+
14+
options = {
15+
configFile = lib.mkOption {
16+
type = lib.types.either wlib.types.linkable lib.types.lines;
17+
default = "";
18+
description = ''
19+
The Hyprland configuration file.
20+
21+
Provide either inlined configuration or reference an external file.
22+
'';
23+
};
24+
25+
"hyprland.lua" = lib.mkOption {
26+
type = wlib.types.file {
27+
path = lib.mkOptionDefault config.constructFiles.generatedConfig.path;
28+
content =
29+
let
30+
getPluginPath =
31+
plugin: if lib.types.package.check plugin then "${plugin}/lib/lib${plugin.pname}.so" else plugin;
32+
33+
pluginLoading =
34+
if config.plugins != [ ] then
35+
''
36+
hl.on("hyprland.start", function()
37+
${lib.concatMapStringsSep "\n" (
38+
plugin: " hl.exec_cmd(\"hyprctl plugin load ${getPluginPath plugin}\")"
39+
) config.plugins}
40+
end)
41+
42+
''
43+
else
44+
"";
45+
46+
userConfigLoading = "dofile(\"${config.constructFiles.userConfig.path}\")";
47+
in
48+
pluginLoading + userConfigLoading;
49+
};
50+
default = { };
51+
description = ''
52+
Hyprland configuration file.
53+
'';
54+
};
55+
56+
plugins = lib.mkOption {
57+
type = lib.types.listOf (lib.types.either lib.types.package lib.types.path);
58+
default = [ ];
59+
description = ''
60+
Plugins to install and load alongside Hyprland.
61+
62+
Make sure to guard your plugin configuration behind
63+
a check whether the plugin is loaded!
64+
'';
65+
};
66+
};
67+
68+
config.package = lib.mkDefault pkgs.hyprland;
69+
config.passthru = config.package.passthru;
70+
71+
config.flags."--config" = config."hyprland.lua".path;
72+
73+
config.constructFiles = {
74+
userConfig =
75+
let
76+
linkable = isLinkable config.configFile;
77+
in
78+
{
79+
content = lib.mkIf (!linkable) config.configFile;
80+
builder = lib.mkIf linkable ''ln -s ${config.configFile} "$2"'';
81+
relPath = "${config.binName}-user.lua";
82+
};
83+
generatedConfig = {
84+
content = config."hyprland.lua".content;
85+
relPath = "${config.binName}.lua";
86+
};
87+
};
88+
89+
config.meta = {
90+
maintainers = [ wlib.maintainers.jonas-elhs ];
91+
platforms = lib.platforms.linux;
92+
};
93+
}

0 commit comments

Comments
 (0)