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. 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 #+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)
# home/desktop/hyprscrolling.nix (Home-Manager module)
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
cfg = config.programs.hyprscrolling; cfg = config.programs.hyprscrolling;
# where your repo keeps the config repoConf = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
defaultConfPath = builtins.path {
path = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
name = "hyprscrolling.conf";
};
# where we place it in ~/.config
targetRel = "hypr/conf.d/90-hyprscrolling.conf"; targetRel = "hypr/conf.d/90-hyprscrolling.conf";
in in
{ {
options.programs.hyprscrolling = { options.programs.hyprscrolling.enable =
enable = lib.mkEnableOption "Hyprland hyprscrolling plugin (Home-Manager)"; lib.mkEnableOption "hyprscrolling Hyprland plugin";
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.";
};
};
config = lib.mkIf cfg.enable { 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 = { wayland.windowManager.hyprland = {
enable = lib.mkDefault true; # the key part: load plugin like you did for hyprshell
# Hyprland HM module supports packages or absolute .so paths here plugins = [ pkgs.hyprlandPlugins.hyprscrolling ];
plugins = [ cfg.pluginPackage ]; # source the generated drop-in
# 2) Source the drop-in so your plugin config is actually applied
extraConfig = lib.mkAfter '' extraConfig = lib.mkAfter ''
# hyprscrolling drop-in source = ~/.config/${targetRel}
source = ~/.config/${cfg.confTargetRel}
''; '';
}; };
# 3) Put your repo conf at ~/.config/hypr/conf.d/90-hyprscrolling.conf # place your repo config into ~/.config/hypr/conf.d/...
xdg.configFile."${cfg.confTargetRel}".source = cfg.confSource; xdg.configFile."${targetRel}".source = repoConf;
}; };
} }
#+end_src #+end_src