How to add custom kodi plugins / yet another "How to use a custom derivation in my flake" post

Hi there, I’m trying to add some Kodi plugins that aren’t/shouldn’t be on nixpkgs.

I’ve created the derivations like this:

# pkgs/upnext/default.nix
{ lib, rel, buildKodiAddon, fetchzip, addonUpdateScript }:

buildKodiAddon rec {
  pname = "upnext";
  namespace = "service.upnext";
  version = "1.1.9+matrix.1";

  src = fetchzip {
    url = "${lib.toLower rel}/${namespace}/${namespace}-${version}.zip";
    sha256 = "";

  passthru = {
    pythonPath = "lib";
    updateScript = addonUpdateScript {
      attrPath = "kodi.packages.upnext";

  meta = with lib; {
    homepage = "";
    description = "Up Next - Proposes to play the next episode automatically";
    license = licenses.gpl2Only;
    maintainers = teams.kodi.members;

And they get called here

# pkgs/default.nix
{ pkgs }:
  upnext = pkgs.callPackage ./upnext {};
  # ... and so on

That in turn is used as an overlay in my flake:

  description = "Sanzoghenzo home systems configuration";
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    deploy-rs.url = "github:serokell/deploy-rs";
    nixos-hardware.url = "github:NixOS/nixos-hardware/master";

  outputs = inputs@{ 
  }: let
    system = "x86_64-linux";
    myPkgsOverlay = final: prev: (import ./pkgs { pkgs = prev; });
    pkgs = import nixpkgs { 
      inherit system pkgs;
      config.allowUnfree = true;
      overlays = [ myPkgsOverlay ];
    deployPkgs = import nixpkgs {
      inherit system;
      config.allowUnfree = true;
      overlays = [
        (self: super: { 
          deploy-rs = { inherit (pkgs) deploy-rs; lib = super.deploy-rs.lib; }; 
  in {
    # systems configuration
    nixosConfigurations = {
      viewscreen = nixpkgs.lib.nixosSystem {
        inherit system;
        modules = [
            home-manager = {
              useGlobalPkgs = true;
              useUserPackages = true;
              users.kodi = import ./home/kodi;

    # devShells and deploy-rs profiles omitted for brevity, they work ok

Then I tried to use the derivations in my home-manager config:

# home/kodi/default.nix
{ self, config, pkgs, ... }: let 
  kodiAndPlugins = pkgs.kodi-gbm.withPackages (kodiPkgs: with kodiPkgs; [
    # other packages...
in {
  programs.kodi = {
    enable = true;
    package = kodiAndPlugins;
    # rest of the configuration...

But I don’t see the addons after applying the flake (via deploy-rs).
I cannot find them in the /nix/store, either.
I might be missing something obvious here, but I can’t figure out what!
Do you see something wrong?

My complete setup can be found here
Thanks in advance for the help!

1 Like

you should definitely contribute this to nixpkgs!

seems that your only mistake was missing something in the addons addon.xml file:

the python code is available under resources/lib, not lib

i copy+pasted your expression and modified your pythonPath = "lib"; to pythonPath = "resources/lib"; and then it worked

looking forward to seeing your PR to nixpkgs, be sure to ping me :wink:

1 Like

Awww shoot, I knew it was that simple :sweat_smile:

Is it normal that I didn’t see any error? How can I debug these kind of situations if they happen again?

I will definitely do it!
How’s the policy about kodi plugins? Should we stick to those present on the official kodi repo, or can we add the “shady kind” :ninja: (another plugin that I’m trying to add is horus for acestream)?

unfortunately no error :pensive: when i package things for kodi and i see nothing the first thing i question i do is look at addon.xml within the code - usually that will show you what is wrong or missing

and you can always post to discourse or directly ping me :+1:

we include many addons which aren’t in the official repo which is great

i don’t know what the official nixpkgs policy is there… :man_shrugging:

maybe create a new topic asking about what sort of software is welcome in nixpkgs

1 Like

Hi there, I’m still struggling with this…

It seems that the pkgs.kodi-gbm.withPackages ignores my packages;
if I move them to home.packages = [ pkgs.upnext ... ]; I can see that the packages are built (and it finally complained about missing hashes), but still I got no addon visible in my kodi :cry:

I should also note that I had to change the pkgs/default.nix file to use pkgs.kodiPackages.callPackage:

  upnext = pkgs.kodiPackages.callPackage ./upnext {};

can you please link me to your branch of nixpkgs with this code? i am happy to poke around so i can explain more accurately


Ho @aanderse, thanks for your help!
I just pushed the viewscreen-power branch

kodiPackages refers to kodi.packages, not kodi-gbm.packages and i think that is probably your issue

try replacing kodiPackages with kodi-gbm.packages and i think that will fix your issue

let me know :+1:

Thank you, that’s the piece I was missing!

Not sure why, but I also had to specify the addons in both the pkgs.kodi-gbm.withPackages and home.packages.

Also, I needed to restart my HTPC two times after applying the config with deploy-rs (I’m using the --boot flag because of some issues with systemd that prevents me to directly activate the new generation)

But now that I think of it, maybe there’s no need to add the packages in both sections, it must be just a matter of reboots… So much time wasted trying things just to realize that I needed one more reboot :sweat:

UPDATE: I just confirmed that I don’t need the home.packages part, I might have been too tired yesterday :sweat_smile:

glad to hear you got it! ping me when you make a PR… sounds like a nice addon to have :smile:

1 Like

I did the PR and pinged you there :wink:
I’m working on another bunch of addons, should I open separate PRs for them or can I create a single PR?

1 Like

separate is better in this case

thanks so much!

1 Like