Skip to content

Commit

Permalink
get rid of lib.uniq
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored and mergify[bot] committed Sep 24, 2024
1 parent 6eb1340 commit 2c3ac40
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions modules/nixos/boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" // {
Expand All @@ -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 [ ])
)
);
};
Expand Down

0 comments on commit 2c3ac40

Please sign in to comment.