diff options
author | Martin Weinelt <mweinelt@users.noreply.github.com> | 2023-05-22 16:00:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-22 16:00:54 +0200 |
commit | 958fc8147251a28a0b7c7e7ed3005c222de7c18c (patch) | |
tree | cab5e43b33a28109615419228b5056f012a5f66d | |
parent | c1f79f54888479a896252393392475d9ff408a29 (diff) | |
parent | eae2018b5402c5c5f7aae91deeadc41e0b4b9b35 (diff) |
Merge pull request #216786 from mweinelt/go2rtc
go2rtc: init at 1.5.0
-rw-r--r-- | nixos/doc/manual/release-notes/rl-2305.section.md | 2 | ||||
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/video/go2rtc/default.nix | 111 | ||||
-rw-r--r-- | pkgs/tools/video/go2rtc/default.nix | 39 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
5 files changed, 155 insertions, 0 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 326e23b3700c7..a9d4f99b798bd 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -64,6 +64,8 @@ In addition to numerous new and upgraded packages, this release has the followin - [gmediarender](https://github.com/hzeller/gmrender-resurrect), a simple, headless UPnP/DLNA renderer. Available as [services.gmediarender](options.html#opt-services.gmediarender.enable). +- [go2rtc](https://github.com/AlexxIT/go2rtc), a camera streaming appliation with support for RTSP, WebRTC, HomeKit, FFMPEG, RTMP and other protocols. Available as [services.go2rtc](options.html#opt-services.go2rtc.enable). + - [harmonia](https://github.com/nix-community/harmonia/), Nix binary cache implemented in rust using libnix-store. Available as [services.harmonia](options.html#opt-services.harmonia.enable). - [hyprland](https://github.com/hyprwm/hyprland), a dynamic tiling Wayland compositor that doesn't sacrifice on its looks. Available as [programs.hyprland](#opt-programs.hyprland.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index d4ea5e63d924c..b83e30a3b5a66 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1150,6 +1150,7 @@ ./services/ttys/gpm.nix ./services/ttys/kmscon.nix ./services/video/epgstation/default.nix + ./services/video/go2rtc/default.nix ./services/video/mirakurun.nix ./services/video/replay-sorcery.nix ./services/video/mediamtx.nix diff --git a/nixos/modules/services/video/go2rtc/default.nix b/nixos/modules/services/video/go2rtc/default.nix new file mode 100644 index 0000000000000..45506d551f1c4 --- /dev/null +++ b/nixos/modules/services/video/go2rtc/default.nix @@ -0,0 +1,111 @@ +{ lib +, config +, options +, pkgs +, ... +}: + +let + inherit (lib) + literalExpression + mdDoc + mkEnableOption + mkOption + mkPackageOptionMD + 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 (mdDoc "go2rtc streaming server"); + + package = mkPackageOptionMD pkgs "go2rtc" { }; + + settings = mkOption { + default = {}; + description = mdDoc '' + 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 = mdDoc '' + 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.getBin pkgs.ffmpeg_6-headless}/bin/ffmpeg"; + defaultText = literalExpression "\${lib.getBin pkgs.ffmpeg_6-headless}/bin/ffmpeg"; + description = mdDoc '' + 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 = mdDoc '' + 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 = { + after = [ + "network-online.target" + ]; + wantedBy = [ + "multi-user.target" + ]; + serviceConfig = { + DynamicUser = true; + User = "go2rtc"; + StateDirectory = "go2rtc"; + ExecStart = "${cfg.package}/bin/go2rtc -config ${configFile}"; + }; + }; + }; +} diff --git a/pkgs/tools/video/go2rtc/default.nix b/pkgs/tools/video/go2rtc/default.nix new file mode 100644 index 0000000000000..9dbd5ff4a5f61 --- /dev/null +++ b/pkgs/tools/video/go2rtc/default.nix @@ -0,0 +1,39 @@ +{ lib +, buildGoModule +, fetchFromGitHub +}: + +buildGoModule rec { + pname = "go2rtc"; + version = "1.5.0"; + + src = fetchFromGitHub { + owner = "AlexxIT"; + repo = "go2rtc"; + rev = "refs/tags/v${version}"; + hash = "sha256-1QCw+/XUV8aoNxo2h+8ud6gx7KMFi4hStf7Ezgg5md8="; + }; + + vendorHash = "sha256-iav7k4HLyXO94qofcHxVxhV8BV2k5oiTtX8kVyxnpoI="; + + buildFlagArrays = [ + "-trimpath" + ]; + + CGO_ENABLED = 0; + + ldflags = [ + "-s" + "-w" + ]; + + doCheck = false; # tests fail + + meta = with lib; { + description = "Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MJPEG, HomeKit, FFmpeg, etc."; + homepage = "https://github.com/AlexxIT/go2rtc"; + changelog = "https://github.com/AlexxIT/go2rtc/releases/tag/v${version}"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4f5133be7e0ba..31b04ef08ac91 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3466,6 +3466,8 @@ with pkgs; }; go2tv-lite = go2tv.override { withGui = false; }; + go2rtc = callPackage ../tools/video/go2rtc { }; + goimapnotify = callPackage ../tools/networking/goimapnotify { }; gojsontoyaml = callPackage ../development/tools/gojsontoyaml { }; |