Files
nixpkgs/nixos/modules/services/video/go2rtc/default.nix
Silvan Mosberger 667d42c00d treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:27:17 +01:00

117 lines
3.0 KiB
Nix

{
lib,
config,
options,
pkgs,
...
}:
let
inherit (lib)
literalExpression
mkEnableOption
mkOption
mkPackageOption
types
;
cfg = config.services.go2rtc;
opt = options.services.go2rtc;
format = pkgs.formats.yaml { };
configFile = format.generate "go2rtc.yaml" cfg.settings;
in
{
meta.buildDocsInSandbox = false;
options.services.go2rtc = with types; {
enable = mkEnableOption "go2rtc streaming server";
package = mkPackageOption pkgs "go2rtc" { };
settings = mkOption {
default = { };
description = ''
go2rtc configuration as a Nix attribute set.
See the [wiki](https://github.com/AlexxIT/go2rtc/wiki/Configuration) for possible configuration options.
'';
type = submodule {
freeformType = format.type;
options = {
# https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#module-api
api = {
listen = mkOption {
type = str;
default = ":1984";
example = "127.0.0.1:1984";
description = ''
API listen address, conforming to a Go address string.
'';
};
};
# https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#source-ffmpeg
ffmpeg = {
bin = mkOption {
type = path;
default = lib.getExe pkgs.ffmpeg-headless;
defaultText = literalExpression "lib.getExe pkgs.ffmpeg-headless";
description = ''
The ffmpeg package to use for transcoding.
'';
};
};
# TODO: https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#module-rtsp
rtsp = {
};
streams = mkOption {
type = attrsOf (either str (listOf str));
default = { };
example = literalExpression ''
{
cam1 = "onvif://admin:password@192.168.1.123:2020";
cam2 = "tcp://192.168.1.123:12345";
}
'';
description = ''
Stream source configuration. Multiple source types are supported.
Check the [configuration reference](https://github.com/AlexxIT/go2rtc/blob/v${cfg.package.version}/README.md#module-streams) for possible options.
'';
};
# TODO: https://github.com/AlexxIT/go2rtc/blob/v1.5.0/README.md#module-webrtc
webrtc = {
};
};
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.go2rtc = {
wants = [ "network-online.target" ];
after = [
"network-online.target"
];
wantedBy = [
"multi-user.target"
];
serviceConfig = {
DynamicUser = true;
User = "go2rtc";
SupplementaryGroups = [
# for v4l2 devices
"video"
];
StateDirectory = "go2rtc";
ExecStart = "${cfg.package}/bin/go2rtc -config ${configFile}";
};
};
};
}