-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a fairly primitive NixOS module, it does not offer RFC42 because it can be hard to get right on the first try. Your deployment on your baremetal system may vary and may require personal overrides. It offers simple defaults for the hugepages setup and kernel modules stuff. If you want a better NixOS module, please chime in with usecases. Signed-off-by: Raito Bezarius <[email protected]>
- Loading branch information
1 parent
e896fe9
commit 669cf96
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ pkgs, config, lib, ... }: | ||
let | ||
inherit (lib) mkEnableOption mkPackageOption mkIf types mkOption; | ||
cfg = config.services.vpp; | ||
in | ||
{ | ||
options.services.vpp = { | ||
enable = mkEnableOption '' | ||
vector packet processing framework. | ||
VPP replaces the Linux network stack by a userspace-based network stack, | ||
driven by `vppctl`. You can enable the Linux Control Plane to continue | ||
to interop with Linux APIs. | ||
''; | ||
|
||
package = mkPackageOption pkgs "vpp" { }; | ||
|
||
configFile = mkOption { | ||
type = types.path; | ||
description = "VPP configuration file for startup"; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
users.groups.vpp = {}; | ||
environment.systemPackages = [ cfg.package ]; | ||
boot.kernel.sysctl = { | ||
"vm.nr_hugepages" = lib.mkDefault 1024; | ||
"max_map_count" = lib.mkDefault 3096; | ||
"hugetlb_shm_group" = lib.mkDefault 0; | ||
# Assert that shm max ≥ total size of hugepages. | ||
"shmmax" = lib.mkDefault 2147483648; | ||
}; | ||
systemd.services.vpp = { | ||
description = "Vector Packet Processing process"; | ||
after = [ "syslog.target" "network.target" "auditd.service" ]; | ||
serviceConfig = { | ||
ExecStartPre = [ | ||
"-${pkgs.coreutils}/bin/rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api" | ||
"-/run/current-system/sw/bin/modprobe uio_pci_generic" | ||
]; | ||
|
||
ExecStart = "${cfg.package}/bin/vpp -c ${cfg.configFile}"; | ||
Type = "simple"; | ||
Restart = "on-failure"; | ||
RestartSec = "5s"; | ||
RuntimeDirectory = "vpp"; | ||
}; | ||
wantedBy = [ "multi-user.target" ]; | ||
}; | ||
}; | ||
} |