summary refs log tree commit diff
path: root/nixos/modules/services/hardware/mdevd.nix
blob: b141bfc875eb5ce15aa9f7daf809c418342b08a6 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ pkgs, lib, config, ... }:

let
  inherit (lib) mkDefault mkIf mkOption;

in {
  options = {
    services.mdevd.enable = mkOption {
      default = false;
      description = "Whether to use the mdevd kernel hotplug management daemon";
    };

    services.mdevd.package = mkOption {
      default = pkgs.mdevd;
      description = "Package providing the mdevd command";
    };

    services.mdevd.verbosity = mkOption {
      default = 1;
      description = "Log level between 0 and 3. 3 is the most verbose.";
    };

    services.mdevd.notif = mkOption {
      default = 3;
      description = "File descriptor to use to notify s6 of readiness.";
      internal = true;
    };

    services.mdevd.kbufsz = mkOption {
      default = 500000;
      description = "Bytes of buffer to reserve for the netlink queue";
    };

    services.mdevd.slashsys = mkOption {
      default = "/sys";
      description = "Location of the sysfs";
    };

    services.mdevd.slashdev = mkOption {
      default = "/dev";
      description = "Location of the device nodes";
    };

    services.mdevd.fwbase = mkOption {
      description = "Location of the firmware files, if any";
    };
  };

  config = mkIf config.services.mdevd.enable {
    services.mdevd.fwbase = mkDefault "${config.hardware.firmware}/lib/firmware";

    # s6.rc.services.mdevd = {
    #   type = "longrun";
    #   notification-fd = config.services.mdevd.notif;
    #   run = ''
    #     #!${pkgs.execline}/bin/execlineb -P
    #     ${config.services.mdevd.package}/bin/mdevd
    #         -v ${toString config.services.mdevd.verbosity}
    #         -D ${toString config.services.mdevd.notif}
    #         -b ${toString config.services.mdevd.kbufsz}
    #         -f ${pkgs.writeText "mdev.conf" ''
    #           SUBSYSTEM=net;.* root:root 600 @${pkgs.nettools}/bin/nameif
    #           tun[0-9]* root:root 600 =net/
    #           tap[0-9]* root:root 600 =net/
    #         ''}
    #         -s ${config.services.mdevd.slashdev}
    #         -F ${config.services.mdevd.fwbase}
    #   '';
    # };
  };
}