Is there a reason to not have the package as a default inside an option?
In particular i stumbled upon the new hardware.graphics.package
and hardware.graphics.package32
options which are only set at runtime, if hardware.graphics.enable = true;
.
config = lib.mkIf cfg.enable {
# ...
hardware.graphics.package = lib.mkDefault pkgs.mesa;
hardware.graphics.package32 = lib.mkDefault pkgs.pkgsi686Linux.mesa;
};
If you reference config.hardware.graphics.package
without setting it and enabling hardware.graphics.enable
you will get an error.
Wouldn’t it be better to put them into the default
in mkOption
like so:?
package = lib.mkOption {
description = ''
The package that provides the default driver set.
'';
type = lib.types.package;
default = pkgs.mesa;
};
or so:?
package = lib.mkPackageOption pkgs "mesa" { };
This way it would be documented, which package is set by default in search.nixos.org/options and you wouldn’t get an error if referencing config.hardware.graphics.package
.