I’m writing a flake for the app Posting. I’ve already successfully packaged the app. I thought it would be nice to add a home-manager module as well, to allow users to configure the app with nix. This would add the option programs.posting
to home-manager. However, I’m struggling to actually add the package to the user’s package list. If the package were in nixpkgs, I could use the mkPackageOption
function with the module’s pkgs argument and the name of the package. However, posting isn’t in nixpkgs and thus isn’t necessarily in the pkgs passed to the module. So how on earth do I get access to my custom package in the module?
You can find my flake here. Maybe I’m just misusing flake-parts? It’s so hard to get any good info on this online.
The way I do this in my systems flake is with overlays.
The flake’s outputs.overlays
includes one with extra packages defined within the flake, and I add that to the overlays used in a given system’s entry in outputs.nixosConfigurations
, e.g with something like this in the modules list:
{ nixpkgs.overlays = [ self.overlays.default ]; }
I imagine the same kind of thing can be used with a home manager configuration as a flake output, for cases where you’re not using nixos and home-manager directly integrated together. You just need to work out how to pass the nixpkgs with your overlay to the home-manager module depending on how you’ve set that up.
As one more concrete example, for some extra home-assistant components I use, packaged locally:
overlays.hacc = final: prev: {
home-assistant-custom-components = prev.home-assistant-custom-components // {
amberelectric_usages = final.home-assistant.python.pkgs.callPackage ./packages/home-assistant-custom-components/amberelectric_usages { };
meross_lan = final.home-assistant.python.pkgs.callPackage ./packages/home-assistant-custom-components/meross_lan { };
smartthinq_sensors = final.home-assistant.python.pkgs.callPackage ./packages/home-assistant-custom-components/smartthinq_sensors { };
};
};
Okay, my ultimate solution to this problem was to create a generic package.nix
module that can be called with pkgs.callPackage
. WIth this, I can expose it as an overlay, using final.callPackage
in the overlay to add the correct system’s package.
I have a new problem, but I’m going to make a new forum post for it.