NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.38k stars 13.61k forks source link

plex-mpv-shim user service #84752

Open matthew-piziak opened 4 years ago

matthew-piziak commented 4 years ago

plex-mpv-shim is now available as a binary on the unstable branch. It is an HTTP server, and should be enabled as a service

I have managed to create a service with the following module:

{ pkgs, config, lib, ... }:
let cfg = config.services.plex-mpv-shim;
in with lib; {
  options.services.plex-mpv-shim = { enable = mkEnableOption "plex-mpv-shim service"; };
  config = mkIf cfg.enable {
    systemd.user.services.plex-mpv-shim = {
      # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/systemd-unit-options.nix#L63
      # https://github.com/markuskowa/NixOS-QChem/blob/ca5f6ab24d3011e868b38b8023c5ae51679a6202/template_module.nix
      wantedBy = [ "multi-user.target" ];
      description = "HTTP server connecting Plex to MPV client";
      serviceConfig = { ExecStart = "${pkgs.plex-mpv-shim}/bin/plex-mpv-shim"; };
    };
  };
}

Currently, this can be started manually with systemctl --user start plex-mpv-shim.

I think it is reasonable that this be a user service, and that we should declaratively perform systemctl --user start plex-mpv-shim somehow. Making it a non-user service means that Plex can find it, but MPV does not show up for the user.

Unfortunately wantedBy = [ "multi-user.target" ] is insufficient to start this automatically upon services.plex-mvp-shim.enable = true.

I am new to NixOS services so I could use some help here. If you are familiar with user services, could you help me fix this module and submit it as a PR to nixpkgs?

stale[bot] commented 3 years ago

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

solson commented 3 years ago

This would be nice to have and I have a similar locally defined service right now. I'm also not very familiar with this area, but I've been using wantedBy = [ "graphical-session.target" ] and it seems to start automatically with no problems.