Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions maintainers/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{ lib }:
{
{ lib }: {
inherit (lib.maintainers) birdee ameer;
patwid = {
name = "Patrick Widmer";
Expand Down Expand Up @@ -116,4 +115,9 @@
github = "aliaslion";
githubId = "122117018";
};
jonas-elhs = {
name = "Jonas Elhs";
github = "jonas-elhs";
githubId = 177471339;
};
}
93 changes: 93 additions & 0 deletions wrapperModules/h/hyprland/module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
config,
wlib,
lib,
pkgs,
...
}:
let
isLinkable = wlib.types.linkable.check;
in
{
imports = [ wlib.modules.default ];

options = {
configFile = lib.mkOption {
type = lib.types.either wlib.types.linkable lib.types.lines;
default = "";
description = ''
The Hyprland configuration file.

Provide either inlined configuration or reference an external file.
'';
};

"hyprland.lua" = lib.mkOption {
type = wlib.types.file {
path = lib.mkOptionDefault config.constructFiles.generatedConfig.path;
content =
let
getPluginPath =
plugin: if lib.types.package.check plugin then "${plugin}/lib/lib${plugin.pname}.so" else plugin;

pluginLoading =
if config.plugins != [ ] then
''
hl.on("hyprland.start", function()
${lib.concatMapStringsSep "\n" (
plugin: " hl.exec_cmd(\"hyprctl plugin load ${getPluginPath plugin}\")"
) config.plugins}
end)

''
else
"";

userConfigLoading = "dofile(\"${config.constructFiles.userConfig.path}\")";
in
pluginLoading + userConfigLoading;
};
default = { };
description = ''
Hyprland configuration file.
'';
};

plugins = lib.mkOption {
type = lib.types.listOf (lib.types.either lib.types.package lib.types.path);
default = [ ];
description = ''
Plugins to install and load alongside Hyprland.

Make sure to guard your plugin configuration behind
a check whether the plugin is loaded!
'';
};
};

config.package = lib.mkDefault pkgs.hyprland;
config.passthru = config.package.passthru;

config.flags."--config" = config."hyprland.lua".path;

config.constructFiles = {
userConfig =
let
linkable = isLinkable config.configFile;
in
{
content = lib.mkIf (!linkable) config.configFile;
builder = lib.mkIf linkable ''ln -s ${config.configFile} "$2"'';
relPath = "${config.binName}-user.lua";
};
generatedConfig = {
content = config."hyprland.lua".content;
relPath = "${config.binName}.lua";
};
};

config.meta = {
maintainers = [ wlib.maintainers.jonas-elhs ];
platforms = lib.platforms.linux;
};
}
Loading