Select the types of activity you want to include in your feed.
lib/options: nullable mkPackageOption
It is sometimes useful to allow setting a package option to `null` to skip installing the package. See https://github.com/nix-community/home-manager/pull/3668#issuecomment-1554044171 for example.
···155155 # Name for the package, shown in option description
156156 name:
157157 {
158158+ # Whether the package can be null, for example to disable installing a package altogether.
159159+ nullable ? false,
158160 # The attribute path where the default package is located (may be omitted)
159161 default ? name,
160162 # A string or an attribute path to use as an example (may be omitted)
···164166 }:
165167 let
166168 name' = if isList name then last name else name;
169169+ in mkOption ({
170170+ type = with lib.types; (if nullable then nullOr else lib.id) package;
171171+ description = "The ${name'} package to use."
172172+ + (if extraDescription == "" then "" else " ") + extraDescription;
173173+ } // (if default != null then let
167174 default' = if isList default then default else [ default ];
168175 defaultPath = concatStringsSep "." default';
169176 defaultValue = attrByPath default'
170177 (throw "${defaultPath} cannot be found in pkgs") pkgs;
171171- in mkOption {
178178+ in {
179179+ default = defaultValue;
172180 defaultText = literalExpression ("pkgs." + defaultPath);
173173- type = lib.types.package;
174174- description = "The ${name'} package to use."
175175- + (if extraDescription == "" then "" else " ") + extraDescription;
176176- ${if default != null then "default" else null} = defaultValue;
177177- ${if example != null then "example" else null} = literalExpression
181181+ } else if nullable then {
182182+ default = null;
183183+ } else { }) // lib.optionalAttrs (example != null) {
184184+ example = literalExpression
178185 (if isList example then "pkgs." + concatStringsSep "." example else example);
179179- };
186186+ });
180187181188 /* Like mkPackageOption, but emit an mdDoc description instead of DocBook. */
182189 mkPackageOptionMD = pkgs: name: extra: