Closed
Description
Nixpkgs has lib.mkPackageOption
(documentation, noogle, source) which takes a "pkgs path" and produces an option with an appropriate default and literalExpression defaultText.
# e.g.
lib.mkPackageOption pkgs "hello" { }
# is like
lib.mkOption {
type = lib.types.package;
default = pkgs.hello;
defaultText = lib.literalExpression "pkgs.hello";
description = "The hello package to use.";
}
We should use this where possible, and copy the implementation in our nullable version.
We could do this in a non-breaking way by having our nullable helper check the pkg
arg type; lists and strings can be pkgs-paths while derivations should be actual packages.
Eventually, we could warn when a derivation is passed in to hunt down any remaining call sites, but I see this more as something that can improve future code rather than something we should be in a hurry to migrate existing code to.
TODO:
- Add support to
mkVimPlugin
andmkNeovimPlugin
lib/*-plugins: initial support forlib.mkPackageOption
#2139 - Implement fancier support (i.e. adding the option within
mkNeovimPlugin
, using an imported module) - Migrate all plugins
defaultPackage
- Remove the deprecated helpers (
mkPackageOption
&mkPluginPackageOption
)