Merge pull request #13861 from abbradar/mjpg-streamer

mjpg-streamer: update and add NixOS service

+94 -20
+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 + }
+17 -20
pkgs/applications/video/mjpg-streamer/default.nix
··· 1 - {stdenv, fetchsvn, pkgconfig, libjpeg, imagemagick, libv4l}: 1 + { stdenv, fetchFromGitHub, cmake, libjpeg }: 2 2 3 3 stdenv.mkDerivation rec { 4 - rev = "182"; 5 - name = "mjpg-streamer-${rev}"; 4 + name = "mjpg-streamer-${version}"; 5 + version = "2016-03-08"; 6 6 7 - src = fetchsvn { 8 - url = https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer/mjpg-streamer; 9 - inherit rev; 10 - sha256 = "008k2wk6xagprbiwk8fvzbz4dd6i8kzrr9n62gj5i1zdv7zcb16q"; 7 + src = fetchFromGitHub { 8 + owner = "jacksonliam"; 9 + repo = "mjpg-streamer"; 10 + rev = "4060cb64e3557037fd404d10e1c1d076b672e9e8"; 11 + sha256 = "0g7y832jsz4ylmq9qp2l4fq6bm8l6dhsbi60fr5jfqpx4l0pia8m"; 11 12 }; 12 13 13 - patchPhase = '' 14 - substituteInPlace Makefile "make -C plugins\/input_gspcav1" "# make -C plugins\/input_gspcav1" 15 - substituteInPlace Makefile "cp plugins\/input_gspcav1\/input_gspcav1.so" "# cp plugins\/input_gspcav1\/input_gspcav1.so" 14 + prePatch = '' 15 + cd mjpg-streamer-experimental 16 16 ''; 17 17 18 - postFixup = '' 19 - patchelf --set-rpath "$(patchelf --print-rpath $out/bin/mjpg_streamer):$out/lib:$out/lib/plugins" $out/bin/mjpg_streamer 20 - ''; 18 + nativeBuildInputs = [ cmake ]; 19 + buildInputs = [ libjpeg ]; 21 20 22 - makeFlags = "DESTDIR=$(out)"; 23 - 24 - preInstall = '' 25 - mkdir -p $out/{bin,lib} 21 + postFixup = '' 22 + patchelf --set-rpath "$(patchelf --print-rpath $out/bin/mjpg_streamer):$out/lib/mjpg-streamer" $out/bin/mjpg_streamer 26 23 ''; 27 24 28 - buildInputs = [ pkgconfig libjpeg imagemagick libv4l ]; 29 - 30 - meta = { 25 + meta = with stdenv.lib; { 31 26 homepage = http://sourceforge.net/projects/mjpg-streamer/; 32 27 description = "MJPG-streamer takes JPGs from Linux-UVC compatible webcams, filesystem or other input plugins and streams them as M-JPEG via HTTP to webbrowsers, VLC and other software"; 28 + platforms = platforms.linux; 29 + licenses = licenses.gpl2; 33 30 }; 34 31 }