|
|
@@ -0,0 +1,110 @@
|
|
|
+{ config, lib, pkgs, ... }:
|
|
|
+
|
|
|
+with lib;
|
|
|
+
|
|
|
+let
|
|
|
+ cfg = config.programs.hyprlandLua;
|
|
|
+
|
|
|
+ mkMonitorLua = m:
|
|
|
+ let
|
|
|
+ mirrorStr = if (m ? mirror && m.mirror != null) then ", mirror = \"${m.mirror}\"" else "";
|
|
|
+ in
|
|
|
+ ''hl.monitor({ output = "${m.output}", mode = "${m.mode}", position = "${m.position}", scale = ${toString m.scale}${mirrorStr} })'';
|
|
|
+
|
|
|
+ mkBindLua = b:
|
|
|
+ ''hl.bind("${b.key}", ${b.action})'';
|
|
|
+
|
|
|
+ mkWorkspaceRules = rules: concatMapStringsSep "\n" (r: ''
|
|
|
+ for i = ${toString r.startIdx}, ${toString r.endIdx} do
|
|
|
+ hl.workspace_rule({ workspace = ${r.formula}, monitor = "${r.monitor}", default = ${boolToString r.default} })
|
|
|
+ end
|
|
|
+ '') rules;
|
|
|
+
|
|
|
+ generatedLua = ''
|
|
|
+ -- Auto-generated by Nix
|
|
|
+ ${optionalString (cfg.shellCommand != "") ''
|
|
|
+ hl.on("hyprland.start", function ()
|
|
|
+ hl.exec_cmd("${cfg.shellCommand}")
|
|
|
+ end)
|
|
|
+ ''}
|
|
|
+
|
|
|
+ mainMod = "${cfg.mainMod}"
|
|
|
+ secMod = "${cfg.secMod}"
|
|
|
+
|
|
|
+ ${concatMapStringsSep "\n" mkBindLua cfg.bindings}
|
|
|
+
|
|
|
+ -- Monitors Configuration
|
|
|
+ ${concatMapStringsSep "\n" mkMonitorLua cfg.monitors}
|
|
|
+
|
|
|
+ -- Workspace Rules
|
|
|
+ ${mkWorkspaceRules cfg.workspaceRules}
|
|
|
+
|
|
|
+ ${optionalString (cfg.defaultCursorMonitor != "") ''
|
|
|
+ hl.config({
|
|
|
+ cursor = {
|
|
|
+ default_monitor = "${cfg.defaultCursorMonitor}"
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ''}
|
|
|
+
|
|
|
+ ${cfg.extraLua}
|
|
|
+ '';
|
|
|
+
|
|
|
+in {
|
|
|
+ options.programs.hyprlandLua = {
|
|
|
+ enable = mkEnableOption "Nix-generated Hyprland Lua configuration";
|
|
|
+
|
|
|
+ shellCommand = mkOption {
|
|
|
+ type = types.str;
|
|
|
+ default = "";
|
|
|
+ example = "dms run";
|
|
|
+ description = "Command executed on hyprland start (e.g. dms-shell, waybar, etc.)";
|
|
|
+ };
|
|
|
+
|
|
|
+ mainMod = mkOption { type = types.str; default = "ALT"; };
|
|
|
+ secMod = mkOption { type = types.str; default = "SUPER"; };
|
|
|
+
|
|
|
+ bindings = mkOption {
|
|
|
+ type = types.listOf (types.submodule {
|
|
|
+ options = {
|
|
|
+ key = mkOption { type = types.str; };
|
|
|
+ action = mkOption { type = types.str; example = ''hl.dsp.exec_cmd("dms screenshot")''; };
|
|
|
+ };
|
|
|
+ });
|
|
|
+ default = [];
|
|
|
+ };
|
|
|
+
|
|
|
+ monitors = mkOption {
|
|
|
+ type = types.listOf (types.submodule {
|
|
|
+ options = {
|
|
|
+ output = mkOption { type = types.str; default = ""; };
|
|
|
+ mode = mkOption { type = types.str; default = "preferred"; };
|
|
|
+ position = mkOption { type = types.str; default = "auto"; };
|
|
|
+ scale = mkOption { type = types.int; default = 1; };
|
|
|
+ mirror = mkOption { type = types.nullOr types.str; default = null; };
|
|
|
+ };
|
|
|
+ });
|
|
|
+ default = [];
|
|
|
+ };
|
|
|
+
|
|
|
+ workspaceRules = mkOption {
|
|
|
+ type = types.listOf (types.submodule {
|
|
|
+ options = {
|
|
|
+ startIdx = mkOption { type = types.int; };
|
|
|
+ endIdx = mkOption { type = types.int; };
|
|
|
+ formula = mkOption { type = types.str; example = "i % 10"; };
|
|
|
+ monitor = mkOption { type = types.str; };
|
|
|
+ default = mkOption { type = types.bool; default = true; };
|
|
|
+ };
|
|
|
+ });
|
|
|
+ default = [];
|
|
|
+ };
|
|
|
+
|
|
|
+ defaultCursorMonitor = mkOption { type = types.str; default = ""; };
|
|
|
+ extraLua = mkOption { type = types.lines; default = ""; };
|
|
|
+ };
|
|
|
+
|
|
|
+ config = mkIf cfg.enable {
|
|
|
+ xdg.configFile."hypr/host_specific.lua".text = generatedLua;
|
|
|
+ };
|
|
|
+}
|