Jump to content

Kodi: Difference between revisions

From NixOS Wiki
imported>Mic92
Add kodi page
 
Tie-ling (talk | contribs)
added gbm variant
 
(14 intermediate revisions by 9 users not shown)
Line 1: Line 1:
Kodi (formerly known as XBMC) is an award-winning free and open source (GPL) software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS and Android, featuring a 10-foot user interface for use with televisions and remote controls.
[https://kodi.tv Kodi] (formerly known as XBMC) is an award-winning free and open source (GPL) software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS and Android, featuring a 10-foot user interface for use with televisions and remote controls.


== Module usage ==
== Basic module usage ==


The NixOS module for kodi sets kodi up as a desktop session.
The NixOS module for Kodi sets Kodi up as a desktop session.
With this configuration kodi will run automatically on boot:
With this configuration Kodi will run automatically on boot:


<syntaxHighlight>
<syntaxhighlight lang="nix">
{
{
   services.xserver.enable = true;
   services.xserver.enable = true;
Line 12: Line 12:
   services.xserver.displayManager.autoLogin.enable = true;
   services.xserver.displayManager.autoLogin.enable = true;
   services.xserver.displayManager.autoLogin.user = "kodi";
   services.xserver.displayManager.autoLogin.user = "kodi";
   users.extraUsers.kodi.isNormalUser = true;
 
   services.xserver.displayManager.lightdm.greeter.enable = false;


   # Define a user account
   # Define a user account
   users.extraUsers.kodi.isNormalUser = true;
   users.extraUsers.kodi.isNormalUser = true;
}
</syntaxhighlight>


  # allow everybody in the net to access the wifi
== Access from other machines ==
 
For this to work Kodi's remote interface must be enabled in the Kodi configuration.
Kodi uses by default udp/tcp port 8080, which must be allowed in the firewall:
 
<syntaxHighlight lang=nix>
{
   networking.firewall = {
   networking.firewall = {
     allowedTCPPorts = [ 8080 ];
     allowedTCPPorts = [ 8080 ];
Line 25: Line 34:
</syntaxHighlight>
</syntaxHighlight>


== With wayland ==
== Autostart kodi-gbm, with HDMI audio passthrough ==
 
From ArchWiki: currently the most feature rich. It is the only one of the three options (x11, wayland, gbm) able to display HDR content, may be a good choice for standalone operations since it runs directly on the GPU without the need for the added X11 layer. A complete list of features lacking compared to other back-ends can be found in Kodi issue 14876.
 
 
<syntaxHighlight lang=nix>
{ pkgs, ... }:
{
  # use alsa; which supports hdmi passthrough
  services.pulseaudio.enable = false;
  services.pipewire.enable = false;
 
  environment.systemPackages = with pkgs; [
    kodi-gbm
  ];
 
  users.users = {
    kodi = {
      initialHashedPassword = "passwordHash";
      extraGroups = [
        # allow kodi access to keyboards
        "input"
      ];
      isNormalUser = true;
    };
  };
 
 
  # auto-login and launch kodi
  services.getty.autologinUser = "kodi";
  services.greetd = {
    enable = true;
    settings = {
      initial_session = {
        command = "${pkgs.kodi-gbm}/bin/kodi-standalone";
        user = "kodi";
      };
      default_session = {
        command = "${pkgs.greetd.greetd}/bin/agreety --cmd sway";
      };
    };
  };
 
  programs.sway = {
    enable = true;
    xwayland.enable = false;
  };
}
</syntaxHighlight>
 
== With Wayland ==


Especially on less-powerful ARM boards the wayland variant is faster.
Especially on less-powerful ARM boards the wayland variant is faster.
In this example cage, kiosk compositor for Wayland, will run kodi as its only application:
In this example cage, kiosk compositor for Wayland, will run Kodi as its only application:


<syntaxHighlight>
<syntaxHighlight lang=nix>
{
{ pkgs, ... }: {
   # Define a user account
   # Define a user account
   users.extraUsers.kodi.isNormalUser = true;
   users.extraUsers.kodi.isNormalUser = true;
Line 39: Line 98:
}
}
</syntaxHighlight>
</syntaxHighlight>
== Plugins ==
There are two different ways to install plugins. You can either set the relevant option (search pkgs/top-level/all-packages.nix for "wrapKodi" for a list) through NixOS or home-manager:
<syntaxHighlight lang=nix>
nixpkgs.config.kodi.enableAdvancedLauncher = true;
</syntaxHighlight>
or override Kodi to include the plugins (see pkgs/applications/video/kodi/plugins.nix for a list or search in the kodiPlugins namespace):
<syntaxHighlight lang=nix>
environment.systemPackages = [
(pkgs.kodi.withPackages (kodiPkgs: with kodiPkgs; [
jellyfin
]))
];
</syntaxHighlight>
Or if using as the startup desktop service:
<syntaxHighlight lang=nix>
  services.xserver.desktopManager.kodi.package =
    pkgs.kodi.withPackages (pkgs: with pkgs; [
    jellycon
]))
];
</syntaxHighlight>
[[Category:Applications]]
[[Category:Server]]

Latest revision as of 21:21, 18 September 2025

Kodi (formerly known as XBMC) is an award-winning free and open source (GPL) software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS and Android, featuring a 10-foot user interface for use with televisions and remote controls.

Basic module usage

The NixOS module for Kodi sets Kodi up as a desktop session. With this configuration Kodi will run automatically on boot:

{
  services.xserver.enable = true;
  services.xserver.desktopManager.kodi.enable = true;
  services.xserver.displayManager.autoLogin.enable = true;
  services.xserver.displayManager.autoLogin.user = "kodi";

  services.xserver.displayManager.lightdm.greeter.enable = false;

  # Define a user account
  users.extraUsers.kodi.isNormalUser = true;
}

Access from other machines

For this to work Kodi's remote interface must be enabled in the Kodi configuration. Kodi uses by default udp/tcp port 8080, which must be allowed in the firewall:

{
  networking.firewall = {
    allowedTCPPorts = [ 8080 ];
    allowedUDPPorts = [ 8080 ];
  };
}

Autostart kodi-gbm, with HDMI audio passthrough

From ArchWiki: currently the most feature rich. It is the only one of the three options (x11, wayland, gbm) able to display HDR content, may be a good choice for standalone operations since it runs directly on the GPU without the need for the added X11 layer. A complete list of features lacking compared to other back-ends can be found in Kodi issue 14876.


{ pkgs, ... }:
{
  # use alsa; which supports hdmi passthrough
  services.pulseaudio.enable = false;
  services.pipewire.enable = false;

  environment.systemPackages = with pkgs; [
    kodi-gbm
  ];

  users.users = {
    kodi = {
      initialHashedPassword = "passwordHash";
      extraGroups = [
        # allow kodi access to keyboards
        "input"
      ];
      isNormalUser = true;
    };
  };


  # auto-login and launch kodi
  services.getty.autologinUser = "kodi";
  services.greetd = {
    enable = true;
    settings = {
      initial_session = {
        command = "${pkgs.kodi-gbm}/bin/kodi-standalone";
        user = "kodi";
      };
      default_session = {
        command = "${pkgs.greetd.greetd}/bin/agreety --cmd sway";
      };
    };
  };

  programs.sway = {
    enable = true;
    xwayland.enable = false;
  };
}

With Wayland

Especially on less-powerful ARM boards the wayland variant is faster. In this example cage, kiosk compositor for Wayland, will run Kodi as its only application:

{ pkgs, ... }: {
  # Define a user account
  users.extraUsers.kodi.isNormalUser = true;
  services.cage.user = "kodi";
  services.cage.program = "${pkgs.kodi-wayland}/bin/kodi-standalone";
  services.cage.enable = true;
}

Plugins

There are two different ways to install plugins. You can either set the relevant option (search pkgs/top-level/all-packages.nix for "wrapKodi" for a list) through NixOS or home-manager:

nixpkgs.config.kodi.enableAdvancedLauncher = true;

or override Kodi to include the plugins (see pkgs/applications/video/kodi/plugins.nix for a list or search in the kodiPlugins namespace):

environment.systemPackages = [
	(pkgs.kodi.withPackages (kodiPkgs: with kodiPkgs; [
		jellyfin
	]))
];

Or if using as the startup desktop service:

  services.xserver.desktopManager.kodi.package =
    pkgs.kodi.withPackages (pkgs: with pkgs; [
    jellycon
	]))
];