diff options
author | Nikolay Amiantov <ab@fmap.me> | 2016-03-14 15:19:03 +0300 |
---|---|---|
committer | Nikolay Amiantov <ab@fmap.me> | 2016-03-14 15:19:03 +0300 |
commit | 363f024864e9f604a3a256cebac97db6e809bcde (patch) | |
tree | a5f5aa9699ae417392ee240a40c7bb8eeccd644c | |
parent | 13c6b9ba8549c3db91c6f321e0413a538bce9388 (diff) | |
parent | 83ff545bfd21815edd0f2ea194d49b198b0ca52b (diff) | |
download | nixlib-363f024864e9f604a3a256cebac97db6e809bcde.tar nixlib-363f024864e9f604a3a256cebac97db6e809bcde.tar.gz nixlib-363f024864e9f604a3a256cebac97db6e809bcde.tar.bz2 nixlib-363f024864e9f604a3a256cebac97db6e809bcde.tar.lz nixlib-363f024864e9f604a3a256cebac97db6e809bcde.tar.xz nixlib-363f024864e9f604a3a256cebac97db6e809bcde.tar.zst nixlib-363f024864e9f604a3a256cebac97db6e809bcde.zip |
Merge pull request #13861 from abbradar/mjpg-streamer
mjpg-streamer: update and add NixOS service
-rw-r--r-- | nixos/modules/misc/ids.nix | 1 | ||||
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/networking/mjpg-streamer.nix | 75 | ||||
-rw-r--r-- | pkgs/applications/video/mjpg-streamer/default.nix | 37 |
4 files changed, 94 insertions, 20 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 0ab2b8a76fc5..919271cc4e96 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -254,6 +254,7 @@ octoprint = 230; avahi-autoipd = 231; nntp-proxy = 232; + mjpg-streamer = 233; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 9f5ba6c9da10..3dd60ad99dca 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -331,6 +331,7 @@ ./services/networking/lambdabot.nix ./services/networking/libreswan.nix ./services/networking/mailpile.nix + ./services/networking/mjpg-streamer.nix ./services/networking/minidlna.nix ./services/networking/miniupnpd.nix ./services/networking/mstpd.nix diff --git a/nixos/modules/services/networking/mjpg-streamer.nix b/nixos/modules/services/networking/mjpg-streamer.nix new file mode 100644 index 000000000000..9986f549aecf --- /dev/null +++ b/nixos/modules/services/networking/mjpg-streamer.nix @@ -0,0 +1,75 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.mjpg-streamer; + +in { + + options = { + + services.mjpg-streamer = { + + enable = mkEnableOption "mjpg-streamer webcam streamer"; + + inputPlugin = mkOption { + type = types.str; + default = "input_uvc.so"; + description = '' + Input plugin. See plugins documentation for more information. + ''; + }; + + outputPlugin = mkOption { + type = types.str; + default = "output_http.so -w @www@ -n -p 5050"; + description = '' + Output plugin. <literal>@www@</literal> is substituted for default mjpg-streamer www directory. + See plugins documentation for more information. + ''; + }; + + user = mkOption { + type = types.str; + default = "mjpg-streamer"; + description = "mjpg-streamer user name."; + }; + + group = mkOption { + type = types.str; + default = "video"; + description = "mjpg-streamer group name."; + }; + + }; + + }; + + config = mkIf cfg.enable { + + users.extraUsers = optional (cfg.user == "mjpg-streamer") { + name = "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; + serviceConfig.Group = cfg.group; + + 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" + ''; + }; + + }; + +} diff --git a/pkgs/applications/video/mjpg-streamer/default.nix b/pkgs/applications/video/mjpg-streamer/default.nix index 7cacc4fcf05e..5409cf9f2f7f 100644 --- a/pkgs/applications/video/mjpg-streamer/default.nix +++ b/pkgs/applications/video/mjpg-streamer/default.nix @@ -1,34 +1,31 @@ -{stdenv, fetchsvn, pkgconfig, libjpeg, imagemagick, libv4l}: +{ stdenv, fetchFromGitHub, cmake, libjpeg }: stdenv.mkDerivation rec { - rev = "182"; - name = "mjpg-streamer-${rev}"; + name = "mjpg-streamer-${version}"; + version = "2016-03-08"; - src = fetchsvn { - url = https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer/mjpg-streamer; - inherit rev; - sha256 = "008k2wk6xagprbiwk8fvzbz4dd6i8kzrr9n62gj5i1zdv7zcb16q"; + src = fetchFromGitHub { + owner = "jacksonliam"; + repo = "mjpg-streamer"; + rev = "4060cb64e3557037fd404d10e1c1d076b672e9e8"; + sha256 = "0g7y832jsz4ylmq9qp2l4fq6bm8l6dhsbi60fr5jfqpx4l0pia8m"; }; - patchPhase = '' - substituteInPlace Makefile "make -C plugins\/input_gspcav1" "# make -C plugins\/input_gspcav1" - substituteInPlace Makefile "cp plugins\/input_gspcav1\/input_gspcav1.so" "# cp plugins\/input_gspcav1\/input_gspcav1.so" + prePatch = '' + cd mjpg-streamer-experimental ''; - postFixup = '' - patchelf --set-rpath "$(patchelf --print-rpath $out/bin/mjpg_streamer):$out/lib:$out/lib/plugins" $out/bin/mjpg_streamer - ''; + nativeBuildInputs = [ cmake ]; + buildInputs = [ libjpeg ]; - makeFlags = "DESTDIR=$(out)"; - - preInstall = '' - mkdir -p $out/{bin,lib} + postFixup = '' + patchelf --set-rpath "$(patchelf --print-rpath $out/bin/mjpg_streamer):$out/lib/mjpg-streamer" $out/bin/mjpg_streamer ''; - buildInputs = [ pkgconfig libjpeg imagemagick libv4l ]; - - meta = { + meta = with stdenv.lib; { homepage = http://sourceforge.net/projects/mjpg-streamer/; 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"; + platforms = platforms.linux; + licenses = licenses.gpl2; }; } |