Override package to install extraPackage from overlay

I am trying to install home-assistant. In my configuration, the application requires an extra python library (pydeconz), which is unfortunately not available in nixpkgs. Therefore, I added it to my system using an overlay (using this code snippet):


self: super:
# Within the overlay we use a recursive set, though I think we can use `self` as well.
rec {
  # nix-shell -p python.pkgs.my_stuff
  python2 = super.python2.override {
    # Careful, we're using a different self and super here!
    packageOverrides = self: super: {
      pydeconz = super.buildPythonPackage rec {
        pname = "pydeconz";
        version = "71";
        # name = "${pname}-${version}";
        src = super.fetchPypi {
          inherit pname version;
          sha256 = "cd7436779296ab259c1e3e02d639a5d6aa7eca300afb03bb5553a787b27e324c";
        };
      };
    };
  };
}

And indeed, when I add pythonPackages.pydeconz to my environment.systemPackages and run nixos-rebuild switch, my system finds and attempts to install that package (although it fails, because pythonPackages seems to be from python2 be default, and pydeconz requires python3).

However, when I now try to add the library to home-assistent as described in its documentation, it fails with the error “attribute pydeconz missing”.

  services.home-assistant = {
    enable = true;
    package = pkgs.home-assistant.override {
      extraPackages = ps: with ps; [ colorlog pythonPackages.pydeconz ]; 
    };
    ...
  };

I would have thought that the packages I get from the homeassistant’s override-callback are affected by my overlay as well such that pydeconz should be accessible from there.
What is wrong with my attempt?

Thank you for any help!

I found another repository that managed to do what I was failing with.
Apparently, the packageOverrides attribute needs to be overwritten to add custom packages:

    package = pkgs.home-assistant.override {
      extraPackages = ps: with ps; [ colorlog pydeconz ];

      packageOverrides = self: super: {
         pydeconz = pkgs.pythonPackages.pydeconz;
      };
    };
1 Like