9 inherit (lib) mkOption types mkIf;
10 cfg = config.services.screego;
12 SCREEGO_SERVER_ADDRESS = "127.0.0.1:5050";
13 SCREEGO_TURN_ADDRESS = "0.0.0.0:3478";
14 SCREEGO_TURN_PORT_RANGE = "50000:55000";
15 SCREEGO_SESSION_TIMEOUT_SECONDS = "0";
16 SCREEGO_CLOSE_ROOM_WHEN_OWNER_LEAVES = "true";
17 SCREEGO_AUTH_MODE = "turn";
18 SCREEGO_LOG_LEVEL = "info";
22 meta.maintainers = with lib.maintainers; [ pinpox ];
24 options.services.screego = {
26 enable = lib.mkEnableOption "screego screen-sharing server for developers";
28 openFirewall = mkOption {
32 Open the firewall port(s).
36 environmentFile = mkOption {
39 Environment file (see {manpage}`systemd.exec(5)` "EnvironmentFile="
40 section for the syntax) passed to the service. This option can be
41 used to safely include secrets in the configuration.
43 example = "/run/secrets/screego-envfile";
44 type = with types; nullOr path;
47 settings = lib.mkOption {
48 type = types.attrsOf types.str;
50 Screego settings passed as Nix attribute set, they will be merged with
51 the defaults. Settings will be passed as environment variables.
53 See https://screego.net/#/config for possible values
55 default = defaultSettings;
57 SCREEGO_EXTERNAL_IP = "dns:example.com";
64 # User-provided settings should be merged with default settings,
65 # overwriting where necessary
66 mergedConfig = defaultSettings // cfg.settings;
67 turnUDPPorts = lib.splitString ":" mergedConfig.SCREEGO_TURN_PORT_RANGE;
68 turnPort = lib.toInt (builtins.elemAt (lib.splitString ":" mergedConfig.SCREEGO_TURN_ADDRESS) 1);
72 networking.firewall = lib.mkIf cfg.openFirewall {
73 allowedTCPPorts = [ turnPort ];
74 allowedUDPPorts = [ turnPort ];
75 allowedUDPPortRanges = [
77 from = lib.toInt (builtins.elemAt turnUDPPorts 0);
78 to = lib.toInt (builtins.elemAt turnUDPPorts 1);
83 systemd.services.screego = {
84 wantedBy = [ "multi-user.target" ];
85 after = [ "network.target" ];
86 description = "screego screen-sharing for developers";
87 environment = mergedConfig;
90 ExecStart = "${lib.getExe pkgs.screego} serve";
91 Restart = "on-failure";
93 } // lib.optionalAttrs (cfg.environmentFile != null) { EnvironmentFile = cfg.environmentFile; };