From f07bc144f7d2c3ecc9ea5dcace28575cafd4aeaa Mon Sep 17 00:00:00 2001 From: Emery Date: Mon, 31 Oct 2022 17:01:46 -0500 Subject: [PATCH] nncp: remove --- flake.nix | 16 -------- hosts/nncp/collectd_nncp.nim | 47 ----------------------- hosts/nncp/default.nix | 72 ------------------------------------ hosts/nncp/eris.nix | 30 --------------- hosts/nncp/neighbours.nix | 19 ---------- modules/nncp.nix | 2 + 6 files changed, 2 insertions(+), 184 deletions(-) delete mode 100644 hosts/nncp/collectd_nncp.nim delete mode 100644 hosts/nncp/default.nix delete mode 100644 hosts/nncp/eris.nix delete mode 100644 hosts/nncp/neighbours.nix diff --git a/flake.nix b/flake.nix index a672a52d..8824537d 100644 --- a/flake.nix +++ b/flake.nix @@ -634,22 +634,6 @@ system = "aarch64-linux"; }; - # nncp = nixosSystem' { - # modules = [ - # self.nixosModules.microvm - # self.nixosModules.nncp - # syndicate.nixosModules.default - # ./hosts/nncp - # { - # nixpkgs.overlays = [ - # syndicate.overlays.default - # eris.inputs.nimble.overlay - # eris.overlays.default - # ]; - # } - # ]; - # }; - dacbert = nixosSystem' { modules = [ nixos-hardware.nixosModules.raspberry-pi-4 diff --git a/hosts/nncp/collectd_nncp.nim b/hosts/nncp/collectd_nncp.nim deleted file mode 100644 index f17a06f7..00000000 --- a/hosts/nncp/collectd_nncp.nim +++ /dev/null @@ -1,47 +0,0 @@ -import std/[os, strutils] - -import posix - -proc getFileSize(path: string): BiggestInt = - var rawInfo: Stat - if stat(path, rawInfo) < 0'i32: - raiseOSError(osLastError(), path) - rawInfo.st_size - -let - hostname = getEnv("COLLECTD_HOSTNAME", "localhost") - interval = max(60, getEnv("COLLECTD_INTERVAL", "0").parseFloat.int) - args = commandLineParams() - -doAssert(args.len == 1, "pass only the NNCP spool directry as an argument") - -type DirStats = tuple[size: BiggestInt, packets: int] - -proc sumDir(path: string): DirStats = - for kind, path in walkDir path: - if kind == pcFile: - result.size = result.size + getFileSize(path) - inc result.packets - -while true: - var stats: tuple[rx: DirStats, tx: DirStats] - for kind, path in walkDir args[0]: - if kind == pcDir: - block: - var rx = sumDir(path / "rx") - stats.rx.size = stats.rx.size + rx.size - stats.rx.packets.inc rx.packets - block: - var tx = sumDir(path / "tx") - stats.tx.size = stats.tx.size + tx.size - stats.tx.packets.inc tx.packets - stdout.writeLine("""PUTVAL "$#/exec-nncp/bytes-rx" interval=$# N:$#""" % - [hostname, $interval, $stats.rx.size]) - stdout.writeLine("""PUTVAL "$#/exec-nncp/pending_operations-rx" interval=$# N:$#""" % - [hostname, $interval, $stats.rx.packets]) - stdout.writeLine("""PUTVAL "$#/exec-nncp/bytes-tx" interval=$# N:$#""" % - [hostname, $interval, $stats.tx.size]) - stdout.writeLine("""PUTVAL "$#/exec-nncp/pending_operations-tx" interval=$# N:$#""" % - [hostname, $interval, $stats.tx.packets]) - flushFile stdout - sleep interval*1000 diff --git a/hosts/nncp/default.nix b/hosts/nncp/default.nix deleted file mode 100644 index c15e0e41..00000000 --- a/hosts/nncp/default.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - imports = [ ./eris.nix ./neighbours.nix ]; - - microvm.interfaces = [ { - type = "tap"; - id = "c3d2-nncp"; - mac = "de:ec:9a:6f:3f:63"; - } ]; - - c3d2.mergeNncpSettings = false; - c3d2.hq.statistics.enable = true; - c3d2.deployment = { - server = "server10"; - mounts = [ "etc" "home" "var"]; - autoNetSetup = false; - }; - - system.stateVersion = "22.05"; - - networking = { - hostName = "nncp"; - firewall.enable = false; - }; - - programs.nncp = { - enable = true; - secrets = [ "/etc/nncp.secrets" ]; - settings = { - mcd-listen = [ "c3d2" ]; - mcd-send.c3d2 = 60; - neigh = # use c3d2.nncp.neigh but remove this node - let - hourlyCall = { - cron = "0 42 * * * * *"; - xx = "tx"; # transmit only - when-tx-exists = true; - }; - in lib.mapAttrs (name: value: - value // { - via = lib.lists.remove "c3d2" value.via; - } // (lib.attrsets.optionalAttrs (value.addrs or { } != { }) { - calls = [ hourlyCall ]; - })) (builtins.removeAttrs config.c3d2.nncp.neigh [ "c3d2" ]); - }; - }; - - services.collectd.plugins.exec = let - util = - pkgs.runCommand "collectd_nncp" { nativeBuildInputs = [ pkgs.nim ]; } '' - cp ${./collectd_nncp.nim} ./collectd_nncp.nim - nim c --nimcache:. -o:$out ./collectd_nncp.nim - ''; - in '' - Exec "${config.services.collectd.user}" "${util}" "${config.programs.nncp.settings.spool}" - ''; - users.groups.uucp.members = [ config.services.collectd.user ]; - - services.nncp = { - caller = { - enable = true; - extraArgs = [ "-autotoss" ]; - }; - daemon = { - enable = true; - socketActivation.enable = false; - extraArgs = [ "-autotoss" ]; - }; - }; - -} diff --git a/hosts/nncp/eris.nix b/hosts/nncp/eris.nix deleted file mode 100644 index ae40d820..00000000 --- a/hosts/nncp/eris.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ pkgs, ... }: - -let home = "/var/spool/eris"; -in { - services.syndicate.eris = { - enable = true; - user = "eris"; - config = [ - (pkgs.writeText "eris.pr" '' - > - - - ? ?cap> $cap [ - - - ] - '') - ]; - }; - - users.groups.eris = { }; - users.users.eris = { - isSystemUser = true; - group = "eris"; - inherit home; - }; -} diff --git a/hosts/nncp/neighbours.nix b/hosts/nncp/neighbours.nix deleted file mode 100644 index d10158ea..00000000 --- a/hosts/nncp/neighbours.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - exec = { - # A command to asynchronously export store paths to a remote caller. - nix-store-export = with pkgs; - [ - (writeScript "nncp-nix-store-export.sh" '' - #!${bash}/bin/bash - set -euo pipefail - ${config.nix.package}/bin/nix-store --export $@ | \ - ${config.programs.nncp.package}/bin/nncp-exec -nice $NNCP_NICE $NNCP_SENDER nix-store-import - '') - ]; - - # A command to import store paths from a remote caller. - nix-store-import = [ "${config.nix.package}/bin/nix-store" "--import" ]; - }; -in { programs.nncp.settings.neigh = { emery = { inherit exec; }; }; } diff --git a/modules/nncp.nix b/modules/nncp.nix index f605a7a7..c0603658 100644 --- a/modules/nncp.nix +++ b/modules/nncp.nix @@ -130,5 +130,7 @@ in wantedBy = [ "sockets.target" ]; socketConfig.Accept = true; }; + } // { + warnings = [ "the C3D2 nncp module may go away" ]; }; } -- 2.42.0