From 049dea28970e86e5b1e25f3770a50c3ba8213979 Mon Sep 17 00:00:00 2001 From: jonas-elhs Date: Sun, 28 Jun 2026 12:40:57 +0200 Subject: [PATCH] feat(wrapperModules.hyprland): init --- maintainers/default.nix | 8 ++- wrapperModules/h/hyprland/module.nix | 93 ++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 wrapperModules/h/hyprland/module.nix diff --git a/maintainers/default.nix b/maintainers/default.nix index ed6c2237..5bec327e 100644 --- a/maintainers/default.nix +++ b/maintainers/default.nix @@ -1,5 +1,4 @@ -{ lib }: -{ +{ lib }: { inherit (lib.maintainers) birdee ameer; patwid = { name = "Patrick Widmer"; @@ -116,4 +115,9 @@ github = "aliaslion"; githubId = "122117018"; }; + jonas-elhs = { + name = "Jonas Elhs"; + github = "jonas-elhs"; + githubId = 177471339; + }; } diff --git a/wrapperModules/h/hyprland/module.nix b/wrapperModules/h/hyprland/module.nix new file mode 100644 index 00000000..96dbb3ba --- /dev/null +++ b/wrapperModules/h/hyprland/module.nix @@ -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; + }; +}