Handy/nix/module.nix
COGnITO (mode: carbon) cf284b1700
feat(nix): NixOS integration — ALSA_PLUGIN_DIR, nixosModule, home-manager module (#1025)
- Set ALSA_PLUGIN_DIR to PipeWire's alsa-lib path in package wrapper
  (NixOS store paths aren't in ALSA's default plugin search)
- Add nixosModules.default: udev rule for /dev/uinput, systemPackages
- Add homeManagerModules.default: systemd user service for autostart

Co-authored-by: zitongcharliedeng <zitongcharliedeng@users.noreply.github.com>
2026-03-16 20:47:32 +08:00

47 lines
1.2 KiB
Nix

# NixOS module for Handy speech-to-text
#
# Handles system-level configuration that the package wrapper cannot:
# - udev rule for /dev/uinput (rdev grab() needs it for virtual input)
#
# Note: users must add themselves to the "input" group for evdev hotkey access.
#
# Usage in your flake:
#
# inputs.handy.url = "github:cjpais/Handy";
#
# nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
# modules = [
# handy.nixosModules.default
# { programs.handy.enable = true; }
# ];
# };
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.handy;
in
{
options.programs.handy = {
enable = lib.mkEnableOption "Handy offline speech-to-text";
package = lib.mkOption {
type = lib.types.package;
defaultText = lib.literalExpression "handy.packages.\${system}.handy";
description = "The Handy package to use.";
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
# rdev grab() creates virtual input devices via /dev/uinput.
# Default permissions are crw------- root root — open it to the input group.
services.udev.extraRules = ''
KERNEL=="uinput", GROUP="input", MODE="0660"
'';
};
}