2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.brltty;
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
targets = [
|
|
|
|
"default.target" "multi-user.target"
|
|
|
|
"rescue.target" "emergency.target"
|
|
|
|
];
|
|
|
|
|
|
|
|
genApiKey = pkgs.writers.writeDash "generate-brlapi-key" ''
|
|
|
|
if ! test -f /etc/brlapi.key; then
|
|
|
|
echo -n generating brlapi key...
|
|
|
|
${pkgs.brltty}/bin/brltty-genkey -f /etc/brlapi.key
|
|
|
|
echo done
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
services.brltty.enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Whether to enable the BRLTTY daemon.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2021-05-20 23:08:51 +00:00
|
|
|
users.users.brltty = {
|
|
|
|
description = "BRLTTY daemon user";
|
|
|
|
group = "brltty";
|
2024-02-29 20:09:43 +00:00
|
|
|
isSystemUser = true;
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
users.groups = {
|
|
|
|
brltty = { };
|
|
|
|
brlapi = { };
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
systemd.services."brltty@".serviceConfig =
|
|
|
|
{ ExecStartPre = "!${genApiKey}"; };
|
|
|
|
|
|
|
|
# Install all upstream-provided files
|
|
|
|
systemd.packages = [ pkgs.brltty ];
|
|
|
|
systemd.tmpfiles.packages = [ pkgs.brltty ];
|
|
|
|
services.udev.packages = [ pkgs.brltty ];
|
|
|
|
environment.systemPackages = [ pkgs.brltty ];
|
|
|
|
|
|
|
|
# Add missing WantedBys (see issue #81138)
|
|
|
|
systemd.paths.brltty.wantedBy = targets;
|
|
|
|
systemd.paths."brltty@".wantedBy = targets;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|