Adapted bindings + installed hyprscrolling
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.programs.hyprscrolling;
|
||||
# Render plugin settings into:
|
||||
# plugin:hyprscrolling {
|
||||
# key = value
|
||||
# }
|
||||
#
|
||||
# Values:
|
||||
# - strings become "..."
|
||||
# - bools become true/false
|
||||
# - ints/floats stay numeric
|
||||
# - lists become [ a b c ] (Hyprland-style arrays)
|
||||
renderValue =
|
||||
v:
|
||||
if lib.isString v then "\"${v}\""
|
||||
else if lib.isBool v then (if v then "true" else "false")
|
||||
else if lib.isInt v || lib.isFloat v then toString v
|
||||
else if lib.isList v then
|
||||
"[ " + (lib.concatStringsSep " " (map renderValue v)) + " ]"
|
||||
else
|
||||
throw "programs.hyprscrolling.settings: unsupported value type: ${builtins.typeOf v}";
|
||||
|
||||
renderSettings =
|
||||
settings:
|
||||
let
|
||||
lines = lib.mapAttrsToList (k: v: " ${k} = ${renderValue v}") settings;
|
||||
in
|
||||
if settings == { } then ""
|
||||
else ''
|
||||
plugin:hyprscrolling {
|
||||
${lib.concatStringsSep "\n" lines}
|
||||
}
|
||||
'';
|
||||
|
||||
defaultPluginPkg =
|
||||
# In nixpkgs this is typically available as pkgs.hyprlandPlugins.hyprscrolling
|
||||
# (names may vary by channel; override via programs.hyprscrolling.pluginPackage if needed).
|
||||
(pkgs.hyprlandPlugins.hyprscrolling or null);
|
||||
|
||||
in
|
||||
{
|
||||
options.programs.hyprscrolling = {
|
||||
enable = lib.mkEnableOption "Hyprland hyprscrolling (scrolling layout) plugin";
|
||||
|
||||
pluginPackage = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.package;
|
||||
default = defaultPluginPkg;
|
||||
description = ''
|
||||
Package that provides the hyprscrolling plugin.
|
||||
Defaults to pkgs.hyprlandPlugins.hyprscrolling when available.
|
||||
'';
|
||||
};
|
||||
|
||||
setAsDefaultLayout = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to set `general:layout = scrolling` in Hyprland.";
|
||||
};
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
default = { };
|
||||
example = {
|
||||
# Example keys (actual keys depend on plugin version)
|
||||
# See hyprscrolling README for supported options.
|
||||
# swipe_fingers = 3;
|
||||
# natural_scroll = true;
|
||||
};
|
||||
description = ''
|
||||
Attribute set rendered into a `plugin:hyprscrolling { ... }` block.
|
||||
Keys/values must match hyprscrolling config options.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
description = "Extra Hyprland config appended after the generated plugin config.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.wayland.windowManager.hyprland.enable or false;
|
||||
message = "programs.hyprscrolling.enable requires wayland.windowManager.hyprland.enable = true;";
|
||||
}
|
||||
{
|
||||
assertion = cfg.pluginPackage != null;
|
||||
message = ''
|
||||
Could not find a default hyprscrolling plugin package in this nixpkgs.
|
||||
Set programs.hyprscrolling.pluginPackage explicitly (either from pkgs or a flake input).
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
wayland.windowManager.hyprland = {
|
||||
plugins = [ cfg.pluginPackage ];
|
||||
|
||||
extraConfig = lib.mkAfter ''
|
||||
${lib.optionalString cfg.setAsDefaultLayout "general { layout = scrolling }"}
|
||||
|
||||
${renderSettings cfg.settings}
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user