Skip to content

Commit

Permalink
nixos/vpp: init
Browse files Browse the repository at this point in the history
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
RaitoBezarius committed Feb 22, 2024
1 parent e896fe9 commit 669cf96
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@
./services/networking/zeronet.nix
./services/networking/zerotierone.nix
./services/networking/znc/default.nix
./services/networking/vpp.nix
./services/printing/cupsd.nix
./services/printing/ipp-usb.nix
./services/printing/cups-pdf.nix
Expand Down
52 changes: 52 additions & 0 deletions nixos/modules/services/networking/vpp.nix
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" ];
};
};
}

0 comments on commit 669cf96

Please sign in to comment.