mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-14 08:04:47 +00:00
![]() When using `lib.optionals`, the return value of both branches of the condition get set as a value to the option. When using `lib.mkIf`, only the positive condition gets set as a value to the option. This small distinction is important when dealing with precedence. For example here, we wanted to set a boot.grub.devices default value with lib.mkDefault, and that was getting overridden with the empty value of `lib.optional (cfg.device != "") cfg.device`. See https://github.com/nix-community/srvos/pull/491#discussion_r1738827651 The general conclusion is that using `lib.mkIf` is preferable to `lib.optional` or `lib.optionals` when setting values in the NixOS module system. |
||
---|---|---|
.. | ||
external | ||
generations-dir | ||
generic-extlinux-compatible | ||
grub | ||
init-script | ||
raspberrypi | ||
systemd-boot | ||
efi.nix | ||
loader.nix |