9 cfg = config.services.hardware.lcd;
10 pkg = lib.getBin pkgs.lcdproc;
12 serverCfg = pkgs.writeText "lcdd.conf" ''
14 DriverPath=${pkg}/lib/lcdproc/
16 Bind=${cfg.serverHost}
17 Port=${toString cfg.serverPort}
18 ${cfg.server.extraConfig}
21 clientCfg = pkgs.writeText "lcdproc.conf" ''
23 Server=${cfg.serverHost}
24 Port=${toString cfg.serverPort}
26 ${cfg.client.extraConfig}
31 Restart = "on-failure";
39 meta.maintainers = with maintainers; [ peterhoeg ];
41 options = with types; {
42 services.hardware.lcd = {
43 serverHost = mkOption {
45 default = "localhost";
46 description = "Host on which LCDd is listening.";
49 serverPort = mkOption {
52 description = "Port on which LCDd is listening.";
59 description = "Enable the LCD panel server (LCDd)";
62 openPorts = mkOption {
65 description = "Open the ports in the firewall";
68 usbPermissions = mkOption {
72 Set group-write permissions on a USB device.
74 A USB connected LCD panel will most likely require having its
75 permissions modified for lcdd to write to it. Enabling this option
76 sets group-write permissions on the device identified by
77 {option}`services.hardware.lcd.usbVid` and
78 {option}`services.hardware.lcd.usbPid`. In order to find the
79 values, you can run the {command}`lsusb` command. Example
83 Bus 005 Device 002: ID 0403:c630 Future Technology Devices International, Ltd lcd2usb interface
86 In this case the vendor id is 0403 and the product id is c630.
93 description = "The vendor ID of the USB device to claim.";
99 description = "The product ID of the USB device to claim.";
102 usbGroup = mkOption {
105 description = "The group to use for settings permissions. This group must exist or you will have to create it.";
108 extraConfig = mkOption {
111 description = "Additional configuration added verbatim to the server config.";
119 description = "Enable the LCD panel client (LCDproc)";
122 extraConfig = mkOption {
125 description = "Additional configuration added verbatim to the client config.";
128 restartForever = mkOption {
131 description = "Try restarting the client forever.";
137 config = mkIf (cfg.server.enable || cfg.client.enable) {
138 networking.firewall.allowedTCPPorts = mkIf (cfg.server.enable && cfg.server.openPorts) [
142 services.udev.extraRules = mkIf (cfg.server.enable && cfg.server.usbPermissions) ''
143 ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="${cfg.server.usbVid}", ATTRS{idProduct}=="${cfg.server.usbPid}", MODE="660", GROUP="${cfg.server.usbGroup}"
147 lcdd = mkIf cfg.server.enable {
148 description = "LCDproc - server";
149 wantedBy = [ "lcd.target" ];
150 serviceConfig = serviceCfg // {
151 ExecStart = "${pkg}/bin/LCDd -f -c ${serverCfg}";
152 SupplementaryGroups = cfg.server.usbGroup;
156 lcdproc = mkIf cfg.client.enable {
157 description = "LCDproc - client";
158 after = [ "lcdd.service" ];
159 wantedBy = [ "lcd.target" ];
160 # Allow restarting for eternity
161 startLimitIntervalSec = lib.mkIf cfg.client.restartForever 0;
162 serviceConfig = serviceCfg // {
163 ExecStart = "${pkg}/bin/lcdproc -f -c ${clientCfg}";
164 # If the server is being restarted at the same time, the client will
165 # fail as it cannot connect, so space it out a bit.
171 systemd.targets.lcd = {
172 description = "LCD client/server";
177 wantedBy = [ "multi-user.target" ];