-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule.nix
39 lines (35 loc) · 1005 Bytes
/
module.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.services.dymoprint;
in {
options.services.dymoprint = {
enable = mkEnableOption "dymoprint service";
port = mkOption {
type = types.int;
default = 8080;
description = ''
Port on which the Dymo printer webservice should listen.
'';
};
openFirewall = mkOption {
type = types.bool;
default = false;
description = ''
Whether to automatically open the specified ports in the firewall.
'';
};
};
config = lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts = if cfg.openFirewall then [ cfg.port ] else [];
systemd.services.dymoprint = {
after = [ "dev-dymoprint.device" ];
wantedBy = [ "dev-dymoprint.device" ];
serviceConfig = {
ExecStart = "${pkgs.dymoprint}/bin/dymo_print_server -a 0.0.0.0 -p ${toString cfg.port}";
DynamicUser = true;
};
};
services.udev.packages = [ pkgs.dymoprint ];
};
}