{ pkgs, config, lib, ... }: let cfg = config.mediacenter.kodi; in with lib; { options = { mediacenter.kodi = { enable = mkEnableOption "kodi"; }; }; config = let user = "kodi"; in lib.mkIf cfg.enable { services.cage = { inherit user; enable = true; program = "${pkgs.kodi-standalone}/bin/kodi-standalone"; }; users.users.kodi = { name = user; isNormalUser = true; extraGroups = [ "audio" "video" "disk" "plugdev" "i2c" "spi" "power" ]; }; networking.firewall.allowedTCPPorts = [8080 9090]; environment.systemPackages = with pkgs; [ kodi-standalone alsa-utils (retroarch.override { cores = with libretro; [ snes9x pcsx-rearmed nestopia ]; }) ]; }; }