summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/misc/hyprwhspr-rs.nix
blob: e21f310ccf3047a0ed8f94c5b848caef79c701e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
  config,
  lib,
  pkgs,
  ...
}:

let
  inherit (lib)
    mkEnableOption
    mkPackageOption
    mkOption
    ;
  cfg = config.services.hyprwhspr-rs;
in
{
  options.services.hyprwhspr-rs = {
    enable = mkEnableOption "hyprwhspr-rs";
    package = mkPackageOption pkgs "hyprwhspr-rs" { };

    environmentFile = mkOption {
      type = lib.types.nullOr lib.types.str;
      default = null;
      example = "/path/to/hyprwhspr_secret_file";
      description = "File containing API keys (GROQ_API_KEY, GEMINI_API_KEY) for remote transcription.";
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.user.services.hyprwhspr-rs = {
      description = "Native speech-to-text voice dictation for Hyprland";

      after = [
        "graphical-session.target"
        "pipewire.service"
      ];
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];

      serviceConfig = {
        ExecStart = lib.getExe cfg.package;
        Restart = "on-failure";
        LoadCredential = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
      };
    };
  };
}