New hyprscrolling.nix, inspired by hyprshell.nix

This commit is contained in:
2026-02-25 15:57:37 +01:00
parent 4c6a2fd8e3
commit 9acfe4b630
+10 -40
View File
@@ -1765,57 +1765,27 @@ in
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
# home/desktop/hyprscrolling.nix (Home-Manager module)
# home/desktop/hyprscrolling.nix (Home-Manager module)
{ config, lib, pkgs, flakeRoot, ... }:
let
cfg = config.programs.hyprscrolling;
# where your repo keeps the config
defaultConfPath = builtins.path {
path = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
name = "hyprscrolling.conf";
};
# where we place it in ~/.config
repoConf = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
targetRel = "hypr/conf.d/90-hyprscrolling.conf";
in
{
options.programs.hyprscrolling = {
enable = lib.mkEnableOption "Hyprland hyprscrolling plugin (Home-Manager)";
pluginPackage = lib.mkOption {
type = lib.types.package;
default = pkgs.hyprlandPlugins.hyprscrolling;
description = "Hyprscrolling plugin package to load via Hyprland HM module.";
};
confSource = lib.mkOption {
type = lib.types.path;
default = defaultConfPath;
description = "Path to hyprscrolling.conf in your repo (flakeRoot).";
};
confTargetRel = lib.mkOption {
type = lib.types.str;
default = targetRel;
description = "Relative path under ~/.config where the config will be placed.";
};
};
options.programs.hyprscrolling.enable =
lib.mkEnableOption "hyprscrolling Hyprland plugin";
config = lib.mkIf cfg.enable {
# Ensure the file exists and Hyprland can load plugins
assertions = [
{
assertion = builtins.pathExists cfg.confSource;
message = "programs.hyprscrolling.confSource does not exist: ${toString cfg.confSource}";
}
];
# 1) Install + load plugin (HM-supported)
wayland.windowManager.hyprland = {
enable = lib.mkDefault true;
# Hyprland HM module supports packages or absolute .so paths here
plugins = [ cfg.pluginPackage ];
# 2) Source the drop-in so your plugin config is actually applied
# the key part: load plugin like you did for hyprshell
plugins = [ pkgs.hyprlandPlugins.hyprscrolling ];
# source the generated drop-in
extraConfig = lib.mkAfter ''
# hyprscrolling drop-in
source = ~/.config/${cfg.confTargetRel}
source = ~/.config/${targetRel}
'';
};
# 3) Put your repo conf at ~/.config/hypr/conf.d/90-hyprscrolling.conf
xdg.configFile."${cfg.confTargetRel}".source = cfg.confSource;
# place your repo config into ~/.config/hypr/conf.d/...
xdg.configFile."${targetRel}".source = repoConf;
};
}
#+end_src