nixpkgs-architecture / pkgs-modules

Working group for using modules for packages
Creative Commons Attribution Share Alike 4.0 International
25 stars 3 forks source link

Idea for package creation: using `mkOption`'s `apply` argument #11

Open Atry opened 1 year ago

Atry commented 1 year ago
{
  options.myPackage = mkOption {
    type = lib.types.submoduleWith {
      modules = [{
        freeformType = lib.types.attrsOf lib.types.anything;
      }];
    };
    apply = pkgs.mkDerivation;
  };
}
infinisil commented 1 year ago

Thanks! For now we're not yet looking at concrete implementations yet, but let's leave this open for then.

Here's some quick thoughts though: apply should generally be discouraged because it's not composable: You can only set it once. Additionally using apply here might lead to the mkDerivation arguments not being inspectable via config.myPackage.* anymore, especially with something like the recently proposed __cleanAttrs (which is generally a good idea).