nixpkgs/nixos/modules/system/boot/loader
zimbatm 1ea32d4f69 nixos/grub: fix value precendence with optional -> mkIf
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.
2024-09-01 12:13:15 +02:00
..
external nixos: remove all uses of lib.mdDoc 2024-04-13 10:07:35 -07:00
generations-dir nixos/system: fix grammatical error in docs 2024-07-25 18:19:35 +02:00
generic-extlinux-compatible nixos: remove all uses of lib.mdDoc 2024-04-13 10:07:35 -07:00
grub nixos/grub: fix value precendence with optional -> mkIf 2024-09-01 12:13:15 +02:00
init-script nixos: remove all uses of lib.mdDoc 2024-04-13 10:07:35 -07:00
raspberrypi nixos: remove all uses of lib.mdDoc 2024-04-13 10:07:35 -07:00
systemd-boot nixos/systemd-boot: remove semicolon 2024-08-24 12:50:26 -07:00
efi.nix nixos: remove all uses of lib.mdDoc 2024-04-13 10:07:35 -07:00
loader.nix nixos: remove all uses of lib.mdDoc 2024-04-13 10:07:35 -07:00