53 lines
2.1 KiB
Nix
53 lines
2.1 KiB
Nix
{ config, lib, pkgs, flakeRoot, ... }:
|
||
let
|
||
cfg = config.programs.hyprscrolling;
|
||
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";
|
||
# 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;
|
||
description = ''
|
||
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)
|
||
dropInPath = lib.mkOption {
|
||
type = lib.types.str;
|
||
default = dropInConfPath;
|
||
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;
|
||
default = stableSoPath;
|
||
description = "Stable path for the plugin shared object (symlinked to the Nix store).";
|
||
};
|
||
};
|
||
config = lib.mkIf cfg.enable {
|
||
assertions = [
|
||
{
|
||
assertion = cfg.pluginPackage != null;
|
||
message = ''
|
||
Could not find hyprscrolling plugin package in this nixpkgs.
|
||
Set programs.hyprscrolling.pluginPackage explicitly (e.g. pkgs.hyprlandPlugins.hyprscrolling).
|
||
'';
|
||
}
|
||
];
|
||
environment.systemPackages = [ cfg.pluginPackage ];
|
||
environment.etc."hypr/plugins/libhyprscrolling.so".source =
|
||
"${cfg.pluginPackage}/lib/libhyprscrolling.so";
|
||
# Now /etc/hypr/conf.d/90-hyprscrolling.conf is exactly your file’s contents
|
||
environment.etc."hypr/conf.d/90-hyprscrolling.conf".text = dropInConf;
|
||
};
|
||
}
|