diff --git a/modules/nixos/boot.nix b/modules/nixos/boot.nix index 3453d6d..17adc2a 100644 --- a/modules/nixos/boot.nix +++ b/modules/nixos/boot.nix @@ -3,6 +3,8 @@ let cfg = config.facter.boot; inherit (config.facter) report; + collectDriver = list: lib.foldl' (lst: value: lst ++ value.driver_modules or [ ]) [ ] list; + stringSet = list: builtins.attrNames (builtins.groupBy lib.id list); in { options.facter.boot.enable = lib.mkEnableOption "Enable the Facter Boot module" // { @@ -12,25 +14,15 @@ in config = with lib; mkIf cfg.enable { - boot.initrd.availableKernelModules = filter (dm: dm != null) ( - unique ( - map - ( - { - driver_module ? null, - ... - }: - driver_module - ) - (flatten [ - # Needed if we want to use the keyboard when things go wrong in the initrd. - (report.hardware.usb_controller or [ ]) - # A disk might be attached. - (report.hardware.firewire_controller or [ ]) - # definitely important - (report.hardware.disk or [ ]) - (report.hardware.storage_controller or [ ]) - ]) + boot.initrd.availableKernelModules = stringSet ( + collectDriver ( + # Needed if we want to use the keyboard when things go wrong in the initrd. + (report.hardware.usb_controller or [ ]) + # A disk might be attached. + ++ (report.hardware.firewire_controller or [ ]) + # definitely important + ++ (report.hardware.disk or [ ]) + ++ (report.hardware.storage_controller or [ ]) ) ); };