@ -5,6 +5,19 @@ with lib;
let
cfg = config . services . brltty ;
targets = [
" d e f a u l t . t a r g e t " " m u l t i - u s e r . t a r g e t "
" r e s c u e . t a r g e t " " e m e r g e n c y . t a r g e t "
] ;
genApiKey = pkgs . writers . writeDash " g e n e r a t e - b r l a p i - k e y " ''
if ! test - f /etc/brlapi.key ; then
echo - n generating brlapi key . . .
$ { pkgs . brltty } /bin/brltty-genkey - f /etc/brlapi.key
echo done
fi
'' ;
in {
options = {
@ -18,33 +31,27 @@ in {
} ;
config = mkIf cfg . enable {
systemd . services . brltty = {
description = " B r a i l l e D e v i c e S u p p o r t " ;
unitConfig = {
Documentation = " h t t p : / / m i e l k e . c c / b r l t t y / " ;
DefaultDependencies = " n o " ;
RequiresMountsFor = " ${ pkgs . brltty } / v a r / l i b / b r l t t y " ;
} ;
serviceConfig = {
ExecStart = " ${ pkgs . brltty } / b i n / b r l t t y - - n o - d a e m o n " ;
Type = " n o t i f y " ;
TimeoutStartSec = 5 ;
TimeoutStopSec = 10 ;
Restart = " a l w a y s " ;
RestartSec = 30 ;
Nice = -10 ;
OOMScoreAdjust = -900 ;
ProtectHome = " r e a d - o n l y " ;
ProtectSystem = " f u l l " ;
SystemCallArchitectures = " n a t i v e " ;
} ;
wants = [ " s y s t e m d - u d e v - s e t t l e . s e r v i c e " ] ;
after = [ " l o c a l - f s . t a r g e t " " s y s t e m d - u d e v - s e t t l e . s e r v i c e " ] ;
before = [ " s y s i n i t . t a r g e t " ] ;
wantedBy = [ " s y s i n i t . t a r g e t " ] ;
users . users . brltty = {
description = " B R L T T Y d a e m o n u s e r " ;
group = " b r l t t y " ;
} ;
users . groups = {
brltty = { } ;
brlapi = { } ;
} ;
systemd . services . " b r l t t y @ " . 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 . " b r l t t y @ " . wantedBy = targets ;
} ;
}