Added conf file for hyprscrolling
This commit is contained in:
+6
-75
@@ -1765,60 +1765,20 @@ in
|
||||
** hyprscrolling
|
||||
This Nix module integrates the hyprscrolling plugin into a Home-Manager managed Hyprland setup in a declarative and reproducible way. It ensures the plugin is installed, optionally switches Hyprland to the scrolling layout, and renders user-defined plugin settings directly into the Hyprland configuration. The goal is to manage the scrolling workspace behavior entirely from Nix instead of maintaining manual edits inside hyprland.conf.
|
||||
#+begin_src nix :tangle home/desktop/hyprscrolling.nix :noweb tangle :mkdirp yes
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, flakeRoot, ... }:
|
||||
let
|
||||
cfg = config.programs.hyprscrolling;
|
||||
|
||||
# Render plugin settings into:
|
||||
# plugin:hyprscrolling {
|
||||
# key = value
|
||||
# }
|
||||
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 = (pkgs.hyprlandPlugins.hyprscrolling or null);
|
||||
|
||||
# Stable paths (avoid pinning /nix/store/... in your hyprland.conf)
|
||||
stableSoPath = "/etc/hypr/plugins/libhyprscrolling.so";
|
||||
dropInConfPath = "/etc/hypr/conf.d/90-hyprscrolling.conf";
|
||||
|
||||
dropInConf = ''
|
||||
# Managed by Nix: programs.hyprscrolling
|
||||
# Load plugin shared object (.so)
|
||||
plugin = ${stableSoPath}
|
||||
|
||||
${lib.optionalString cfg.setAsDefaultLayout ''
|
||||
general {
|
||||
layout = scrolling
|
||||
}
|
||||
''}
|
||||
|
||||
${renderSettings cfg.settings}
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
# Read drop-in config from your repo (flake root)
|
||||
dropInConfSourcePath = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
|
||||
dropInConf = builtins.readFile dropInConfSourcePath;
|
||||
in
|
||||
{
|
||||
options.programs.hyprscrolling = {
|
||||
enable = lib.mkEnableOption "Hyprland hyprscrolling (scrolling layout) plugin (NixOS-friendly)";
|
||||
|
||||
pluginPackage = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.package;
|
||||
default = defaultPluginPkg;
|
||||
@@ -1827,35 +1787,12 @@ in
|
||||
Defaults to pkgs.hyprlandPlugins.hyprscrolling when available.
|
||||
'';
|
||||
};
|
||||
|
||||
setAsDefaultLayout = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to set `general { layout = scrolling }` in the generated drop-in config.";
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
default = { };
|
||||
description = ''
|
||||
Attribute set rendered into a `plugin:hyprscrolling { ... }` block
|
||||
in the generated drop-in config.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
description = "Extra Hyprland config appended to the generated drop-in config.";
|
||||
};
|
||||
|
||||
# Where we install the generated config snippet (so you can `source = ...` it)
|
||||
dropInPath = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = dropInConfPath;
|
||||
description = "Path to the generated Hyprland drop-in config file (needs to be sourced by your hyprland.conf).";
|
||||
description = "Path to the Hyprland drop-in config file (needs to be sourced by your hyprland.conf).";
|
||||
};
|
||||
|
||||
# Where we install a stable symlink to the plugin .so
|
||||
stablePluginSoPath = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
@@ -1863,7 +1800,6 @@ in
|
||||
description = "Stable path for the plugin shared object (symlinked to the Nix store).";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
@@ -1874,15 +1810,10 @@ in
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
# Ensure the plugin is built and available.
|
||||
environment.systemPackages = [ cfg.pluginPackage ];
|
||||
|
||||
# Provide a stable .so path under /etc (no /nix/store hardcoding in hyprland.conf)
|
||||
environment.etc."hypr/plugins/libhyprscrolling.so".source =
|
||||
"${cfg.pluginPackage}/lib/libhyprscrolling.so";
|
||||
|
||||
# Provide a drop-in config file under /etc.
|
||||
# Now /etc/hypr/conf.d/90-hyprscrolling.conf is exactly your file’s contents
|
||||
environment.etc."hypr/conf.d/90-hyprscrolling.conf".text = dropInConf;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user