Rewrite of hyprscrolling.nix
This commit is contained in:
+35
-33
@@ -1764,56 +1764,58 @@ in
|
|||||||
** hyprscrolling
|
** 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.
|
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)
|
||||||
{ config, lib, pkgs, flakeRoot, ... }:
|
{ config, lib, pkgs, flakeRoot, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.programs.hyprscrolling;
|
cfg = config.programs.hyprscrolling;
|
||||||
defaultPluginPkg = (pkgs.hyprlandPlugins.hyprscrolling or null);
|
# where your repo keeps the config
|
||||||
# Stable paths (avoid pinning /nix/store/... in your hyprland.conf)
|
defaultConfPath = builtins.path {
|
||||||
stableSoPath = "/etc/hypr/plugins/libhyprscrolling.so";
|
path = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
|
||||||
dropInConfPath = "/etc/hypr/conf.d/90-hyprscrolling.conf";
|
name = "hyprscrolling.conf";
|
||||||
# Read drop-in config from your repo (flake root)
|
};
|
||||||
dropInConfSourcePath = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
|
# where we place it in ~/.config
|
||||||
dropInConf = builtins.readFile dropInConfSourcePath;
|
targetRel = "hypr/conf.d/90-hyprscrolling.conf";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.programs.hyprscrolling = {
|
options.programs.hyprscrolling = {
|
||||||
enable = lib.mkEnableOption "Hyprland hyprscrolling (scrolling layout) plugin (NixOS-friendly)";
|
enable = lib.mkEnableOption "Hyprland hyprscrolling plugin (Home-Manager)";
|
||||||
pluginPackage = lib.mkOption {
|
pluginPackage = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.package;
|
type = lib.types.package;
|
||||||
default = defaultPluginPkg;
|
default = pkgs.hyprlandPlugins.hyprscrolling;
|
||||||
description = ''
|
description = "Hyprscrolling plugin package to load via Hyprland HM module.";
|
||||||
Package that provides the hyprscrolling plugin.
|
|
||||||
Defaults to pkgs.hyprlandPlugins.hyprscrolling when available.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
# Where we install the generated config snippet (so you can `source = ...` it)
|
confSource = lib.mkOption {
|
||||||
dropInPath = lib.mkOption {
|
type = lib.types.path;
|
||||||
type = lib.types.str;
|
default = defaultConfPath;
|
||||||
default = dropInConfPath;
|
description = "Path to hyprscrolling.conf in your repo (flakeRoot).";
|
||||||
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
|
confTargetRel = lib.mkOption {
|
||||||
stablePluginSoPath = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = stableSoPath;
|
default = targetRel;
|
||||||
description = "Stable path for the plugin shared object (symlinked to the Nix store).";
|
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 = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = cfg.pluginPackage != null;
|
assertion = builtins.pathExists cfg.confSource;
|
||||||
message = ''
|
message = "programs.hyprscrolling.confSource does not exist: ${toString cfg.confSource}";
|
||||||
Could not find hyprscrolling plugin package in this nixpkgs.
|
|
||||||
Set programs.hyprscrolling.pluginPackage explicitly (e.g. pkgs.hyprlandPlugins.hyprscrolling).
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
environment.systemPackages = [ cfg.pluginPackage ];
|
# 1) Install + load plugin (HM-supported)
|
||||||
environment.etc."hypr/plugins/libhyprscrolling.so".source =
|
wayland.windowManager.hyprland = {
|
||||||
"${cfg.pluginPackage}/lib/libhyprscrolling.so";
|
enable = lib.mkDefault true;
|
||||||
# Now /etc/hypr/conf.d/90-hyprscrolling.conf is exactly your file’s contents
|
# Hyprland HM module supports packages or absolute .so paths here
|
||||||
environment.etc."hypr/conf.d/90-hyprscrolling.conf".text = dropInConf;
|
plugins = [ cfg.pluginPackage ];
|
||||||
|
# 2) Source the drop-in so your plugin config is actually applied
|
||||||
|
extraConfig = lib.mkAfter ''
|
||||||
|
# hyprscrolling drop-in
|
||||||
|
source = ~/.config/${cfg.confTargetRel}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
# 3) Put your repo conf at ~/.config/hypr/conf.d/90-hyprscrolling.conf
|
||||||
|
xdg.configFile."${cfg.confTargetRel}".source = cfg.confSource;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|||||||
Reference in New Issue
Block a user