at 23.05-pre 1.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.ympd; 7in { 8 9 ###### interface 10 11 options = { 12 13 services.ympd = { 14 15 enable = mkEnableOption (lib.mdDoc "ympd, the MPD Web GUI"); 16 17 webPort = mkOption { 18 type = types.either types.str types.port; # string for backwards compat 19 default = "8080"; 20 description = lib.mdDoc "The port where ympd's web interface will be available."; 21 example = "ssl://8080:/path/to/ssl-private-key.pem"; 22 }; 23 24 mpd = { 25 host = mkOption { 26 type = types.str; 27 default = "localhost"; 28 description = lib.mdDoc "The host where MPD is listening."; 29 }; 30 31 port = mkOption { 32 type = types.port; 33 default = config.services.mpd.network.port; 34 defaultText = literalExpression "config.services.mpd.network.port"; 35 description = lib.mdDoc "The port where MPD is listening."; 36 example = 6600; 37 }; 38 }; 39 40 }; 41 42 }; 43 44 45 ###### implementation 46 47 config = mkIf cfg.enable { 48 49 systemd.services.ympd = { 50 description = "Standalone MPD Web GUI written in C"; 51 wantedBy = [ "multi-user.target" ]; 52 serviceConfig.ExecStart = "${pkgs.ympd}/bin/ympd --host ${cfg.mpd.host} --port ${toString cfg.mpd.port} --webport ${toString cfg.webPort} --user nobody"; 53 }; 54 55 }; 56 57}