I have a package.nix
that looks something like:
{lib, stdenv, makeWrapper}:
let
baseName = "my-package";
version = "0.0.0";
src = ./.;
in {
"${baseName}" = stdenv.mkDerivation {
pname = baseName;
inherit version src;
# do stuff ...
};
"${baseName}-auxiliary" = stdenv.mkDerivation {
pname = "${baseName}-auxiliary";
inherit version src;
# do stuff ...
};
}
Since both of these packages are small and trivial, I thought it would be nice for them to share a lot of the configuration in the let
block.
I tried to use it in a NixOS module as:
defaultPackage = (pkgs.callPackage ./package.nix {}).my-package-auxiliary;
Both derivations are provided as default packages in modules, which are very similar. One is for NixOS, and the other is for Home Manager.
When I try to .override
one of the packages I am told there is no such attribute override
. Do I need to put these in a package scope to make callPackage
work? I thought I could just make the package an attribute set without passing it through mkDerivation
, and that callPackage
would figure it out, evidently this is not the case.