nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 pkg-config,
6 python3,
7 bluez,
8 tcl,
9 acl,
10 kmod,
11 coreutils,
12 shadow,
13 util-linux,
14 alsaSupport ? stdenv.hostPlatform.isLinux,
15 alsa-lib,
16 systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd,
17 systemd,
18 ncurses,
19 udevCheckHook,
20 buildPackages,
21}:
22
23stdenv.mkDerivation rec {
24 pname = "brltty";
25 version = "6.8";
26
27 src = fetchurl {
28 url = "https://brltty.app/archive/brltty-${version}.tar.gz";
29 sha256 = "sha256-MoDYjHU6aJY9e5cgjm9InOEDGCs+jvlEurMWg9wo4RY=";
30 };
31
32 nativeBuildInputs = [
33 pkg-config
34 python3.pkgs.cython
35 python3.pkgs.setuptools
36 tcl # One of build scripts require tclsh
37 udevCheckHook
38 ];
39 buildInputs = [
40 bluez
41 ncurses.dev
42 tcl # For TCL bindings
43 ]
44 ++ lib.optional alsaSupport alsa-lib
45 ++ lib.optional systemdSupport systemd;
46
47 doInstallCheck = true;
48
49 meta = {
50 description = "Access software for a blind person using a braille display";
51 longDescription = ''
52 BRLTTY is a background process (daemon) which provides access to the Linux/Unix
53 console (when in text mode) for a blind person using a refreshable braille display.
54 It drives the braille display, and provides complete screen review functionality.
55 Some speech capability has also been incorporated.
56 '';
57 homepage = "https://brltty.app";
58 license = lib.licenses.gpl2Plus;
59 maintainers = [ lib.maintainers.bramd ];
60 platforms = lib.platforms.all;
61 };
62
63 makeFlags = [
64 "PYTHON_PREFIX=$(out)"
65 "SYSTEMD_UNITS_DIRECTORY=$(out)/lib/systemd/system"
66 "SYSTEMD_USERS_DIRECTORY=$(out)/lib/sysusers.d"
67 "SYSTEMD_FILES_DIRECTORY=$(out)/lib/tmpfiles.d"
68 "UDEV_PARENT_LOCATION=$(out)/lib"
69 "INSTALL_COMMANDS_DIRECTORY=$(out)/libexec/brltty"
70 "UDEV_RULES_TYPE=all"
71 "POLKIT_POLICY_DIR=$(out)/share/polkit-1/actions"
72 "POLKIT_RULE_DIR=$(out)/share/polkit-1/rules.d"
73 "TCL_DIR=$(out)/lib"
74 ];
75 configureFlags = [
76 "--with-writable-directory=/run/brltty"
77 "--with-updatable-directory=/var/lib/brltty"
78 "--with-api-socket-path=/var/lib/BrlAPI"
79 ];
80 installFlags = [
81 "install-systemd"
82 "install-udev"
83 "install-polkit"
84 ];
85
86 env = lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
87 # Build platform compilers for mk4build and second pass of ./configure
88 CC_FOR_BUILD = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc";
89 };
90
91 preConfigure = ''
92 substituteInPlace configure --replace-fail "/sbin/ldconfig -n" "true"
93
94 # Some script needs a working tclsh shebang
95 patchShebangs .
96
97 # Skip impure operations
98 substituteInPlace Programs/Makefile.in \
99 --replace-fail install-apisoc-directory "" \
100 --replace-fail install-api-key ""
101 ''
102 + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
103 # ./configure call itself second time for build platform, if it fail -- it fails silently, make it visible
104 # (this is not mandatory changing, but make further maintaining easier)
105 substituteInPlace mk4build \
106 --replace-fail "--quiet" ""
107 # Respect targetPrefix when invoking ar
108 substituteInPlace Programs/Makefile.in \
109 --replace-fail "ar " "$AR "
110 '';
111
112 postInstall = ''
113 # Rewrite absolute paths
114 substituteInPlace $out/bin/brltty-mkuser \
115 --replace '/sbin/nologin' '${shadow}/bin/nologin'
116 (
117 cd $out/lib
118 substituteInPlace systemd/system/brltty@.service \
119 --replace '/sbin/modprobe' '${kmod}/bin/modprobe'
120 # Ensure the systemd-wrapper script uses the correct path to the brltty binary
121 sed "/^Environment=\"BRLTTY_EXECUTABLE_ARGUMENTS.*/a Environment=\"BRLTTY_EXECUTABLE_PATH=$out/bin/brltty\"" -i systemd/system/brltty@.service
122 substituteInPlace systemd/system/brltty-device@.service \
123 --replace '/usr/bin/true' '${coreutils}/bin/true'
124 substituteInPlace udev/rules.d/90-brltty-uinput.rules \
125 --replace '/usr/bin/setfacl' '${acl}/bin/setfacl'
126 substituteInPlace udev/rules.d/90-brltty-hid.rules \
127 --replace '/usr/bin/setfacl' '${acl}/bin/setfacl'
128 substituteInPlace tmpfiles.d/brltty.conf \
129 --replace "$out/etc" '/etc'
130
131 # Remove unused commands from udev rules
132 sed '/initctl/d' -i udev/rules.d/90-brltty-usb-generic.rules
133 sed '/initctl/d' -i udev/rules.d/90-brltty-usb-customized.rules
134 # Remove pulse-access group from systemd unit and sysusers
135 substituteInPlace systemd/system/brltty@.service \
136 --replace 'SupplementaryGroups=pulse-access' '# SupplementaryGroups=pulse-access'
137 substituteInPlace sysusers.d/brltty.conf \
138 --replace 'm brltty pulse-access' '# m brltty pulse-access'
139 )
140 substituteInPlace $out/libexec/brltty/systemd-wrapper \
141 --replace 'logger' "${util-linux}/bin/logger" \
142 --replace 'udevadm' "${systemd}/bin/udevadm"
143 '';
144}