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

(Hi there! forgive me if I’m necroposting here, but I think it is better to continue the conversation here instead of scattering information around…)

I just installed kodi in wayland as per the wiki, and used the paragraph after that to install the plugins. In there, the second option is to add them to environment.systemPackages, they don’t show up as already reported by others.

Are the two options of using home manager and xserver.desktopManager my only choices?

I would have preferred to stay with wayland and not use home-manager since it is an HTPC with no “real” user access

OK, I just moved to home-manager to be able to configure kodi and enable the web server.
Addons gets installed in the /nix/store folder, but I still don’t see any plugin in the kodi interface.

I’ve published my flake here, I’m using deploy-rs to push the setup to my htpc.

Here’s how I declare the plugins:

looking at the kodi log, I can see that the addons folder is set to a non existing one:

info <general>: special://xbmcbinaddons/ is mapped to: /nix/store/dhxbrm5xrzz1rgcmc8fzx82qywmkxixx-kodi-20.5/lib/kodi/addons
...
error <general>: GetDirectory - Error getting /nix/store/dhxbrm5xrzz1rgcmc8fzx82qywmkxixx-kodi-20.5/lib/kodi/addons

Is this a bug or am I doing something wrong?

did you go into the ‘my addons’ menu and check if they are in there? maybe you need to enable them

Hi @aanderse, thanks for the feedback.

I might have overlooked that, but I’m pretty sure that the only option was to install them and not enable them.

I tried to switch to the xserver.desktopManager config, and at the next boot I got kodi asking me to enable the plugins.
The log still complains about the missing addin folder, so I presume this is not the cause of kodi-wayland not loading the plugins.
At this point I’m worried I’m overlaying too many things on the running system, it’s better if I start from scratch with a VM to do more thorough testing.

ok sounds good

i am one of the kodi maintainers so please keep me up to date on this and if you continue to have problems then let’s move this to a gothub issue with a reproducible example

thanks!

1 Like

OK, I’ve got it working using home manager, kodi-gbm and a user systemd service!
Not sure what caused to finally detect the addons since I suppose I missed some reboots between tries…

For posterity, here’s the home manager config that worked

Awesome! Good to hear you got it.

I had never looked at the home manager kodi module until you mentioned it. I see they offer settings… very nice. I’ll have to look into that for the NixOS module.