1 { config, lib, pkgs, ... }:
3 cfg = config.services.fanout;
4 mknodCmds = n: lib.lists.imap0 (i: s:
5 "mknod /dev/fanout${builtins.toString i} c $MAJOR ${builtins.toString i}"
6 ) (lib.lists.replicate n "");
9 options.services.fanout = {
10 enable = lib.mkEnableOption "fanout";
11 fanoutDevices = lib.mkOption {
14 description = "Number of /dev/fanout devices";
16 bufferSize = lib.mkOption {
19 description = "Size of /dev/fanout buffer in bytes";
23 config = lib.mkIf cfg.enable {
24 boot.extraModulePackages = [ config.boot.kernelPackages.fanout.out ];
26 boot.kernelModules = [ "fanout" ];
28 boot.extraModprobeConfig = ''
29 options fanout buffersize=${builtins.toString cfg.bufferSize}
32 systemd.services.fanout = {
33 description = "Bring up /dev/fanout devices";
35 MAJOR=$(${pkgs.gnugrep}/bin/grep fanout /proc/devices | ${pkgs.gawk}/bin/awk '{print $1}')
36 ${lib.strings.concatLines (mknodCmds cfg.fanoutDevices)}
39 wantedBy = [ "multi-user.target" ];
44 RemainAfterExit = "yes";