17 cfg = config.services.go2rtc;
18 opt = options.services.go2rtc;
20 format = pkgs.formats.yaml {};
21 configFile = format.generate "go2rtc.yaml" cfg.settings;
25 meta.buildDocsInSandbox = false;
27 options.services.go2rtc = with types; {
28 enable = mkEnableOption "go2rtc streaming server";
30 package = mkPackageOption pkgs "go2rtc" { };
35 go2rtc configuration as a Nix attribute set.
37 See the [wiki](https://github.com/AlexxIT/go2rtc/wiki/Configuration) for possible configuration options.
40 freeformType = format.type;
42 # https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#module-api
47 example = "127.0.0.1:1984";
49 API listen address, conforming to a Go address string.
54 # https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#source-ffmpeg
58 default = lib.getExe pkgs.ffmpeg-headless;
59 defaultText = literalExpression "lib.getExe pkgs.ffmpeg-headless";
61 The ffmpeg package to use for transcoding.
66 # TODO: https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#module-rtsp
71 type = attrsOf (either str (listOf str));
73 example = literalExpression ''
75 cam1 = "onvif://admin:password@192.168.1.123:2020";
76 cam2 = "tcp://192.168.1.123:12345";
80 Stream source configuration. Multiple source types are supported.
82 Check the [configuration reference](https://github.com/AlexxIT/go2rtc/blob/v${cfg.package.version}/README.md#module-streams) for possible options.
86 # TODO: https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#module-webrtc
94 config = lib.mkIf cfg.enable {
95 systemd.services.go2rtc = {
96 wants = [ "network-online.target" ];
98 "network-online.target"
106 SupplementaryGroups = [
110 StateDirectory = "go2rtc";
111 ExecStart = "${cfg.package}/bin/go2rtc -config ${configFile}";