{ pkgs, config, lib, ... }: let cfg = config.mediacenter.kodi; in with lib; { options = { mediacenter.kodi = { enable = mkEnableOption "kodi"; }; }; config = let user = "kodi"; starter = pkgs.callPackage ( {pkgs, kodi-standalone, ...}: pkgs.writeShellApplication { name = "kodi-launcher"; runtimeInputs = [kodi-standalone]; text = '' #!/usr/bin/env bash while true do ping -c1 svartalbenheim.odie.home.arpa && break sleep 5 done while true do sleep 1 kodi-standalone done ''; } ) {}; in lib.mkIf cfg.enable { services.cage = { inherit user; enable = true; program = "${starter}/bin/kodi-launcher"; }; 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 ]; }) ]; }; }