tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
mjpg-streamer service: init
Nikolay Amiantov
10 years ago
83ff545b
84e8fece
+77
3 changed files
expand all
collapse all
unified
split
nixos
modules
misc
ids.nix
module-list.nix
services
networking
mjpg-streamer.nix
+1
nixos/modules/misc/ids.nix
···
254
254
octoprint = 230;
255
255
avahi-autoipd = 231;
256
256
nntp-proxy = 232;
257
257
+
mjpg-streamer = 233;
257
258
258
259
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
259
260
+1
nixos/modules/module-list.nix
···
331
331
./services/networking/lambdabot.nix
332
332
./services/networking/libreswan.nix
333
333
./services/networking/mailpile.nix
334
334
+
./services/networking/mjpg-streamer.nix
334
335
./services/networking/minidlna.nix
335
336
./services/networking/miniupnpd.nix
336
337
./services/networking/mstpd.nix
+75
nixos/modules/services/networking/mjpg-streamer.nix
···
1
1
+
{ config, lib, pkgs, ... }:
2
2
+
3
3
+
with lib;
4
4
+
5
5
+
let
6
6
+
7
7
+
cfg = config.services.mjpg-streamer;
8
8
+
9
9
+
in {
10
10
+
11
11
+
options = {
12
12
+
13
13
+
services.mjpg-streamer = {
14
14
+
15
15
+
enable = mkEnableOption "mjpg-streamer webcam streamer";
16
16
+
17
17
+
inputPlugin = mkOption {
18
18
+
type = types.str;
19
19
+
default = "input_uvc.so";
20
20
+
description = ''
21
21
+
Input plugin. See plugins documentation for more information.
22
22
+
'';
23
23
+
};
24
24
+
25
25
+
outputPlugin = mkOption {
26
26
+
type = types.str;
27
27
+
default = "output_http.so -w @www@ -n -p 5050";
28
28
+
description = ''
29
29
+
Output plugin. <literal>@www@</literal> is substituted for default mjpg-streamer www directory.
30
30
+
See plugins documentation for more information.
31
31
+
'';
32
32
+
};
33
33
+
34
34
+
user = mkOption {
35
35
+
type = types.str;
36
36
+
default = "mjpg-streamer";
37
37
+
description = "mjpg-streamer user name.";
38
38
+
};
39
39
+
40
40
+
group = mkOption {
41
41
+
type = types.str;
42
42
+
default = "video";
43
43
+
description = "mjpg-streamer group name.";
44
44
+
};
45
45
+
46
46
+
};
47
47
+
48
48
+
};
49
49
+
50
50
+
config = mkIf cfg.enable {
51
51
+
52
52
+
users.extraUsers = optional (cfg.user == "mjpg-streamer") {
53
53
+
name = "mjpg-streamer";
54
54
+
uid = config.ids.uids.mjpg-streamer;
55
55
+
group = cfg.group;
56
56
+
};
57
57
+
58
58
+
systemd.services.mjpg-streamer = {
59
59
+
description = "mjpg-streamer webcam streamer";
60
60
+
wantedBy = [ "multi-user.target" ];
61
61
+
62
62
+
serviceConfig.User = cfg.user;
63
63
+
serviceConfig.Group = cfg.group;
64
64
+
65
65
+
script = ''
66
66
+
IPLUGIN="${cfg.inputPlugin}"
67
67
+
OPLUGIN="${cfg.outputPlugin}"
68
68
+
OPLUGIN="''${OPLUGIN//@www@/${pkgs.mjpg-streamer}/share/mjpg-streamer/www}"
69
69
+
exec ${pkgs.mjpg-streamer}/bin/mjpg_streamer -i "$IPLUGIN" -o "$OPLUGIN"
70
70
+
'';
71
71
+
};
72
72
+
73
73
+
};
74
74
+
75
75
+
}