mjpg-streamer service: init

+77
+1
nixos/modules/misc/ids.nix
··· 254 254 octoprint = 230; 255 255 avahi-autoipd = 231; 256 256 nntp-proxy = 232; 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 + ./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 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + 7 + cfg = config.services.mjpg-streamer; 8 + 9 + in { 10 + 11 + options = { 12 + 13 + services.mjpg-streamer = { 14 + 15 + enable = mkEnableOption "mjpg-streamer webcam streamer"; 16 + 17 + inputPlugin = mkOption { 18 + type = types.str; 19 + default = "input_uvc.so"; 20 + description = '' 21 + Input plugin. See plugins documentation for more information. 22 + ''; 23 + }; 24 + 25 + outputPlugin = mkOption { 26 + type = types.str; 27 + default = "output_http.so -w @www@ -n -p 5050"; 28 + description = '' 29 + Output plugin. <literal>@www@</literal> is substituted for default mjpg-streamer www directory. 30 + See plugins documentation for more information. 31 + ''; 32 + }; 33 + 34 + user = mkOption { 35 + type = types.str; 36 + default = "mjpg-streamer"; 37 + description = "mjpg-streamer user name."; 38 + }; 39 + 40 + group = mkOption { 41 + type = types.str; 42 + default = "video"; 43 + description = "mjpg-streamer group name."; 44 + }; 45 + 46 + }; 47 + 48 + }; 49 + 50 + config = mkIf cfg.enable { 51 + 52 + users.extraUsers = optional (cfg.user == "mjpg-streamer") { 53 + name = "mjpg-streamer"; 54 + uid = config.ids.uids.mjpg-streamer; 55 + group = cfg.group; 56 + }; 57 + 58 + systemd.services.mjpg-streamer = { 59 + description = "mjpg-streamer webcam streamer"; 60 + wantedBy = [ "multi-user.target" ]; 61 + 62 + serviceConfig.User = cfg.user; 63 + serviceConfig.Group = cfg.group; 64 + 65 + script = '' 66 + IPLUGIN="${cfg.inputPlugin}" 67 + OPLUGIN="${cfg.outputPlugin}" 68 + OPLUGIN="''${OPLUGIN//@www@/${pkgs.mjpg-streamer}/share/mjpg-streamer/www}" 69 + exec ${pkgs.mjpg-streamer}/bin/mjpg_streamer -i "$IPLUGIN" -o "$OPLUGIN" 70 + ''; 71 + }; 72 + 73 + }; 74 + 75 + }