mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-12 03:56:17 +03:00
ef176dcf7e
conversions were done using https://github.com/pennae/nix-doc-munge using (probably) rev f34e145 running nix-doc-munge nixos/**/*.nix nix-doc-munge --import nixos/**/*.nix the tool ensures that only changes that could affect the generated manual *but don't* are committed, other changes require manual review and are discarded.
81 lines
1.8 KiB
Nix
81 lines
1.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.mjpg-streamer;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.mjpg-streamer = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "mjpg-streamer webcam streamer");
|
|
|
|
inputPlugin = mkOption {
|
|
type = types.str;
|
|
default = "input_uvc.so";
|
|
description = lib.mdDoc ''
|
|
Input plugin. See plugins documentation for more information.
|
|
'';
|
|
};
|
|
|
|
outputPlugin = mkOption {
|
|
type = types.str;
|
|
default = "output_http.so -w @www@ -n -p 5050";
|
|
description = lib.mdDoc ''
|
|
Output plugin. `@www@` is substituted for default mjpg-streamer www directory.
|
|
See plugins documentation for more information.
|
|
'';
|
|
};
|
|
|
|
user = mkOption {
|
|
type = types.str;
|
|
default = "mjpg-streamer";
|
|
description = lib.mdDoc "mjpg-streamer user name.";
|
|
};
|
|
|
|
group = mkOption {
|
|
type = types.str;
|
|
default = "video";
|
|
description = lib.mdDoc "mjpg-streamer group name.";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.users = optionalAttrs (cfg.user == "mjpg-streamer") {
|
|
mjpg-streamer = {
|
|
uid = config.ids.uids.mjpg-streamer;
|
|
group = cfg.group;
|
|
};
|
|
};
|
|
|
|
systemd.services.mjpg-streamer = {
|
|
description = "mjpg-streamer webcam streamer";
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
User = cfg.user;
|
|
Group = cfg.group;
|
|
Restart = "on-failure";
|
|
RestartSec = 1;
|
|
};
|
|
|
|
script = ''
|
|
IPLUGIN="${cfg.inputPlugin}"
|
|
OPLUGIN="${cfg.outputPlugin}"
|
|
OPLUGIN="''${OPLUGIN//@www@/${pkgs.mjpg-streamer}/share/mjpg-streamer/www}"
|
|
exec ${pkgs.mjpg-streamer}/bin/mjpg_streamer -i "$IPLUGIN" -o "$OPLUGIN"
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|