fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7jsonFormat = pkgs . formats . json { }; 8cfg = config . services . plex-mpv-shim ; 9 10in { 11meta . maintainers = [ maintainers . starcraft66 ]; 12 13options = { 14services . plex-mpv-shim = { 15enable = mkEnableOption "Plex mpv shim" ; 16 17package = mkOption { 18type = types . package ; 19default = pkgs . plex-mpv-shim ; 20defaultText = literalExpression "pkgs.plex-mpv-shim" ; 21description = "The package to use for the Plex mpv shim." ; 22}; 23 24settings = mkOption { 25type = jsonFormat . type ; 26default = { }; 27example = literalExpression '' 28{ 29adaptive_transcode = false; 30allow_http = false; 31always_transcode = false; 32audio_ac3passthrough = false; 33audio_dtspassthrough = false; 34auto_play = true; 35auto_transcode = true; 36} 37'' ; 38description = '' 39Configuration written to 40{file}`$XDG_CONFIG_HOME/plex-mpv-shim/config.json`. See 41<https://github.com/iwalton3/plex-mpv-shim/blob/master/README.md> 42for the configuration documentation. 43'' ; 44}; 45}; 46}; 47 48config = mkIf cfg . enable { 49assertions = [ 50( lib . hm . assertions . assertPlatform "services.plex-mpv-shim" pkgs 51lib . platforms . linux ) 52]; 53 54xdg . configFile . "plex-mpv-shim/conf.json" = mkIf ( cfg . settings != { }) { 55source = jsonFormat . generate "conf.json" cfg . settings ; 56}; 57 58systemd . user . services . plex-mpv-shim = { 59Unit = { 60Description = "Plex mpv shim" ; 61After = [ "graphical-session-pre.target" ]; 62PartOf = [ "graphical-session.target" ]; 63}; 64 65Service = { ExecStart = " ${ cfg . package } /bin/plex-mpv-shim" ; }; 66 67Install = { WantedBy = [ "graphical-session.target" ]; }; 68}; 69}; 70}