From 2c3ac40acc87cb4f7c2b61c421e0622343a10b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 24 Sep 2024 16:40:10 +0200 Subject: [PATCH] get rid of lib.uniq --- modules/nixos/boot.nix | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) 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 [ ]) ) ); };