hex/nix/hm-module.nix
Dax 3434eb5f35
Rename voice-control to hex everywhere, without migrations (#293)
* Rename voice-control to hex everywhere, without migrations

The Cargo package and binary are now hex, every OS keeps its data in a
hex folder, and VOICE_CONTROL_* variables are HEX_*. Hex is a fresh
app: the macOS voice-control rename, its symlink, and the Windows and
Linux beta settings imports are gone. The Windows installer gets a new
AppId so it never takes over an old voice-control install's entry.

* Format

* Drop the Windows paste-last default only the beta import used
2026-10-28 13:08:44 -04:00

69 lines
2 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.hex;
waitForSession = pkgs.writeShellApplication {
name = "hex-wait-for-session";
runtimeInputs = [
pkgs.coreutils
pkgs.gnugrep
pkgs.xprop
];
text = builtins.readFile ./wait-for-session.sh;
};
in
{
options.programs.hex = {
enable = lib.mkEnableOption "Hex local voice dictation";
package = lib.mkOption {
type = lib.types.package;
description = "Hex package to install.";
};
autostart = lib.mkEnableOption "Hex startup with the graphical session";
systemdTarget = lib.mkOption {
type = lib.types.str;
default = "graphical-session.target";
example = "sway-session.target";
description = ''
User target that owns the graphical session. The compositor or session
manager must import its display environment before starting this target,
and stop the target at logout. This module does not start a session.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = pkgs.stdenv.hostPlatform.system == "x86_64-linux";
message = "The Hex Nix package supports x86_64-linux only.";
}
];
home.packages = [ cfg.package ];
systemd.user.services.hex = {
Unit = {
Description = "Hex local voice dictation";
After = [ cfg.systemdTarget ];
PartOf = [ cfg.systemdTarget ];
};
Service = {
Type = "notify";
NotifyAccess = "main";
ExecStartPre = lib.getExe waitForSession;
ExecStart = "${lib.getExe cfg.package} service";
Environment = [ "HEX_APPLICATION_SUPPORT_DIR=${config.xdg.dataHome}/hex" ];
EnvironmentFile = "-${config.xdg.dataHome}/hex/session.env";
TimeoutStartSec = 35;
Restart = "on-failure";
RestartSec = 5;
TimeoutStopSec = 30;
UMask = "0077";
};
Install.WantedBy = lib.optionals cfg.autostart [ cfg.systemdTarget ];
};
};
}