Right way to install Kodi and plugins?

So, I’ve been using NixOS for a bit now, but I’m pretty confused about getting Kodi to work. I’m also new to Kodi, so its likely that I’m doing something wrong.

I have the following file: kodi.nix which I’m importing to configuration.nix.

However, I see no plugins on the interface. There seems to be conflicting documentation on the NixOS wiki vs. some GitHub issues like these.

Almost. Take your kodi expression and put in services.xserver.desktopManager.kodi.package instead of environment.systemPackages.

Let me know if you have any issues.

1 Like

That did the trick! Thanks!
I had been toying with that idea, but my impression was modifying the systemPackages would wire it in directly.

Glad to hear you’re up and running!

On a sidenote: Is it just me or is Kodi pretty unstable?
I’ve been having crashes with YouTube, Netflix (with DRM etc.).

I used the netflix plugin for roughly 10 months and found it to be reasonably stable. Sometimes kodi just randomly crashes, but all my htpc boxes launch kodi as a systemd user service that have automatic restarts enabled so a crash in the menu isn’t a huge deal.

Every once in a while I wonder what it would take for me to switch from kodi to something else but cec integration combined with my steam plugin really makes kodi unbeatable for my family… so we just live with the occasional crash once in a while :man_shrugging:

I’ve even been debating just going for something like XFCE and using a bluetooth mouse/touchpad as a remote. With some optimizations (onscreen keyboards etc.), I believe a setup like that could even offer tremendous flexibility without having to deal with Kodi (and all the plugins that have not really been stable for me, at least).

So if you use this code below in your configuration.nix you can install plugins on Kodi?

services.xserver.desktopManager.kodi.package  = [
  (kodiPlugins.kodiWithPlugins (pkgs: with pkgs; [
      kodiPlugins.osmc-skin
  ]))
];

Try this instead:

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

1 Like

I try to install a whole bunch of plugins to test if I want them or not, but this returns in errors.

The code:

    ### Audio & Video
    kodi

    ### Kodi Packages
    kodiPackages.kodi
    kodiPackages.six
    kodiPackages.idna
    kodiPackages.iagl
    kodiPackages.trakt
    kodiPackages.arrow
    kodiPackages.kodi-six
    kodiPackages.keymap
    kodiPackages.future
    kodiPackages.youtube
    kodiPackages.urllib3
    kodiPackages.svtplay
    kodiPackages.signals
    kodiPackages.routing
    kodiPackages.pvr-hts
    kodiPackages.netflix
    kodiPackages.chardet
    kodiPackages.certifi
    kodiPackages.vfs-sftp
    kodiPackages.requests
    kodiPackages.myconnpy
    kodiPackages.libretro
    kodiPackages.joystick
    kodiPackages.jellyfin
    kodiPackages.dateutil
    kodiPackages.websocket
    kodiPackages.pdfreader
    kodiPackages.osmc-skin
    kodiPackages.orftvthek
    kodiPackages.invidious
    kodiPackages.xbmcswift2
    kodiPackages.simplejson
    kodiPackages.defusedxml
    kodiPackages.kodi-platform
    kodiPackages.trakt-module
    kodiPackages.arteplussept
    kodiPackages.archive_tool
    kodiPackages.a4ksubtitles
    kodiPackages.steam-library
    kodiPackages.pvr-hdhomerun
    kodiPackages.libretro-mgba
    kodiPackages.vfs-libarchive
    kodiPackages.steam-launcher
    kodiPackages.requests-cache
    kodiPackages.pvr-iptvsimple
    kodiPackages.libretro-snes9x
    kodiPackages.steam-controller
    kodiPackages.libretro-genplus
    kodiPackages.inputstream-rtmp
    kodiPackages.typing_extensions
    kodiPackages.inputstreamhelper
    kodiPackages.inputstream-adaptive
    kodiPackages.inputstream-ffmpegdirect
    kodiPackages.controller-topology-project

  ### Kodi + Plugins
  services.xserver.desktopManager.kodi.enable = true;
  services.xserver.desktopManager.kodi.package = kodi.withPackages (pkgs: with pkgs; [ kodi six idna iagl trakt arrow kodi-six keymap future youtube urllib3 svtplay signals routing pvr-hts netflix chardet certifi vfs-sftp requests myconnpy libretro joystick jellyfin dateutil websocket pdfreader osmc-skin orftvthek invidious xbmcswift2 simplejson defusedxml kodi-platform trakt-module arteplussept archive_tool a4ksubtitles steam-library pvr-hdhomerun libretro-mgba vfs-libarchive steam-launcher requests-cache pvr-iptvsimple libretro-snes9x steam-controller libretro-genplus inputstream-rtmp typing_extensions inputstreamhelper inputstream-adaptive inputstream-ffmpegdirect controller-topology-project ]);
 

The Errors:

error: undefined variable 'kodi'

       at /etc/nixos/configuration.nix:424:50:

          423|   services.xserver.desktopManager.kodi.enable = true;
          424|   services.xserver.desktopManager.kodi.package = kodi.withPackages (pkgs: with pkgs; [ kodi six idna iagl trakt arrow kodi-six keymap future youtube urllib3 svtplay signals routing pvr-hts netflix chardet certifi vfs-sftp requests myconnpy libretro joystick jellyfin dateutil websocket pdfreader osmc-skin orftvthek invidious xbmcswift2 simplejson defusedxml kodi-platform trakt-module arteplussept archive_tool a4ksubtitles steam-library pvr-hdhomerun libretro-mgba vfs-libarchive steam-launcher requests-cache pvr-iptvsimple libretro-snes9x steam-controller libretro-genplus inputstream-rtmp typing_extensions inputstreamhelper inputstream-adaptive inputstream-ffmpegdirect controller-topology-project ]);
             |                                                  ^
          425|

We’ll need to see more of your code, kodi is simply not in scope. You’re probably missing a pkgs. or an inherit (pkgs) kodi or a with kodi; somewhere.

Perhaps all you need to change is to use pkgs.kodi.withPackages, but I’m very suspicious of all the lines before that.

Here is the full configuration.

Yep, that’s the problem.

kodi isn’t a magic globally available variable (the only such variable in nix land is builtins), it’s stored inside of the pkgs that is passed as an argument to your module (where you write { config, pkgs, ... }:) - NixOS handles handing the pkgs variable to your module, but it’s up to you to use it correctly.

So when you type kodi.withPackages, nix has no idea what you mean, because kodi does not exist.

There are three ways to access the variable:

  • Instead of using kodi, use pkgs.kodi, that will take the kodi attribute in pkgs and simply use it.
    • In this case, you should probably do that.
  • At the very top of the file, after you define your inputs, use let inherit (pkgs) kodi; in, that will copy the kodi out of pkgs and make it available as kodi directly
    • This is useful for library functions
  • You can use with pkgs; to make all variables inside pkgs available within the next expression
    • You already do that with environment.systemPackages as well as in the kodi.withPackages call, but it’s best avoided when you do anything but list packages to install.

So in this case, just change your line to:

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

Another side note from me, when you use a definition like services.xserver.desktopManager.kodi.enable, or programs.steam.enable, that package will already be installed.

Also adding it to environment.systemPackages at best does nothing, but at worst it will cause you to use the wrong package and just break. I believe that steam should not be working for you in some cases, for example.

2 Likes