about summary refs log tree commit diff
path: root/modules/system/kernel/bfq/default.nix
blob: a6e7e4d123f96d9186ba87504aa92cbcf99065c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ config, lib, ... }:

let
  inherit (config.boot.kernelPackages.kernel) version;
  inherit (lib) optionalString versionAtLeast versionOlder;
in {
  options.vuizvui.system.kernel.bfq = {
    enable = lib.mkEnableOption "Enable the BFQ scheduler by default";
  };

  config = lib.mkIf config.vuizvui.system.kernel.bfq.enable {
    boot.kernelPatches = lib.singleton {
      name = "bfq";
      patch = ./bfq-by-default.patch;
      extraConfig = ''
        ${optionalString (versionOlder version "4.13") "SCSI_MQ_DEFAULT y"}
        DM_MQ_DEFAULT y
        IOSCHED_BFQ y
        BFQ_GROUP_IOSCHED y
      '';
    };

    vuizvui.requiresTests = lib.singleton ["vuizvui" "system" "kernel" "bfq"];

    assertions = lib.singleton {
      assertion = versionAtLeast version "4.12";

      message = "The BFQ scheduler in conjunction with blk-mq requires "
              + "at least kernel 4.12.";
    };
  };
}