summary refs log tree commit diff
path: root/nixos/modules/services/hardware/mdevd.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/services/hardware/mdevd.nix')
-rw-r--r--nixos/modules/services/hardware/mdevd.nix71
1 files changed, 71 insertions, 0 deletions
diff --git a/nixos/modules/services/hardware/mdevd.nix b/nixos/modules/services/hardware/mdevd.nix
new file mode 100644
index 000000000000..b141bfc875eb
--- /dev/null
+++ b/nixos/modules/services/hardware/mdevd.nix
@@ -0,0 +1,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}
+    #   '';
+    # };
+  };
+}