mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-27 02:34:53 +00:00
Remove optional builtins prefixes from prelude functions by running:
builtins=(
abort
baseNameOf
break
derivation
derivationStrict
dirOf
false
fetchGit
fetchMercurial
fetchTarball
fetchTree
fromTOML
import
isNull
map
null
placeholder
removeAttrs
scopedImport
throw
toString
true
)
fd \
--exclude doc/manual/release-notes \
--type file \
. \
nixos \
--exec-batch sed --in-place --regexp-extended "
s/\<builtins\.($(
printf '%s\n' "${builtins[@]}" |
paste --delimiter '|' --serial -
))\>/\1/g
"
nix fmt
57 lines
1.3 KiB
Nix
57 lines
1.3 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.fanout;
|
|
mknodCmds =
|
|
n:
|
|
lib.lists.imap0 (i: s: "mknod /dev/fanout${toString i} c $MAJOR ${toString i}") (
|
|
lib.lists.replicate n ""
|
|
);
|
|
in
|
|
{
|
|
options.services.fanout = {
|
|
enable = lib.mkEnableOption "fanout";
|
|
fanoutDevices = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 1;
|
|
description = "Number of /dev/fanout devices";
|
|
};
|
|
bufferSize = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 16384;
|
|
description = "Size of /dev/fanout buffer in bytes";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
boot.extraModulePackages = [ config.boot.kernelPackages.fanout.out ];
|
|
|
|
boot.kernelModules = [ "fanout" ];
|
|
|
|
boot.extraModprobeConfig = ''
|
|
options fanout buffersize=${toString cfg.bufferSize}
|
|
'';
|
|
|
|
systemd.services.fanout = {
|
|
description = "Bring up /dev/fanout devices";
|
|
script = ''
|
|
MAJOR=$(${pkgs.gnugrep}/bin/grep fanout /proc/devices | ${pkgs.gawk}/bin/awk '{print $1}')
|
|
${lib.strings.concatLines (mknodCmds cfg.fanoutDevices)}
|
|
'';
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = "root";
|
|
RemainAfterExit = "yes";
|
|
Restart = "no";
|
|
};
|
|
};
|
|
};
|
|
}
|