{ inputs, config, lib, pkgs, ... }: let cfg = config.modules.desktop.vinput; vinput = inputs.fcitx5-vinput.packages.${pkgs.stdenv.hostPlatform.system}.fcitx5-vinput; in { options.modules.desktop.vinput.enable = lib.mkEnableOption "Fcitx5 Vinput voice input"; config = lib.mkIf cfg.enable { i18n.inputMethod.fcitx5.addons = [ vinput ]; # MenuKey opens the command palette; set it to right Ctrl. `CommandKeys` # (voice command on the selection) defaults to right Ctrl and outranks # `MenuKey`, so clear it or the palette never opens. List options use # fcitx5's `[Option]` + `0=` form, not upstream's `[Trigger]` shorthand. xdg.configFile."fcitx5/conf/vinput.conf" = { text = '' [MenuKey] 0=Control_R [CommandKeys] ''; # fcitx5 rewrites this file at runtime, like `profile` and `config`. force = true; }; # The daemon rewrites this itself (the GUI, `vinput scene edit`) and resolves symlinks before # writing, so the link keeps those edits in the checkout instead of a read-only store copy. # `force` retakes the path if a write ever leaves a real file there. See the README. xdg.configFile."vinput/config.json" = { source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/nix-config/home/linux/gui/base/vinput/config.json"; force = true; }; # The OpenAI-transcription client vinput runs as a provider. config.json points at this # absolute path, so the two must stay in sync. xdg.configFile."vinput/aqua-asr-provider".source = pkgs.writers.writePython3 "vinput-aqua-asr-provider" { } ./aqua-provider.py; systemd.user.services.vinput-daemon = { Unit = { Description = "Fcitx5 Vinput voice input daemon"; After = [ "pipewire.service" ]; PartOf = [ "graphical-session.target" ]; }; Service = { Type = "dbus"; BusName = "org.fcitx.Vinput"; ExecStart = "${vinput}/bin/vinput-daemon"; # Provider keys are `{{env.*}}` references the daemon resolves from its own environment, # and a systemd user service inherits neither the interactive shell's environment nor any # app's env file. No `-` prefix: a host without the file is misconfigured, not # half-working, and the daemon logs "unset or empty" without it. EnvironmentFile = "%h/.secrets/nushell-secrets.env"; Restart = "on-failure"; RestartSec = 3; }; Install.WantedBy = [ "graphical-session.target" ]; }; }; }