lol

nixos/nncp: add caller and daemon services

authored by

Emery Hemingway and committed by
Jörg Thalheim
55c8f51a e0dad2b2

+134
+2
nixos/doc/manual/release-notes/rl-2311.section.md
··· 53 53 - [Honk](https://humungus.tedunangst.com/r/honk), a complete ActivityPub server with minimal setup and support costs. 54 54 Available as [services.honk](#opt-services.honk.enable). 55 55 56 + - [NNCP](http://www.nncpgo.org/). Added nncp-daemon and nncp-caller services. Configuration is set with [programs.nncp.settings](#opt-programs.nncp.settings) and the daemons are enabled at [services.nncp](#opt-services.nncp.caller.enable). 57 + 56 58 ## Backward Incompatibilities {#sec-release-23.11-incompatibilities} 57 59 58 60 - The `boot.loader.raspberryPi` options have been marked deprecated, with intent for removal for NixOS 24.11. They had a limited use-case, and do not work like people expect. They required either very old installs ([before mid-2019](https://github.com/NixOS/nixpkgs/pull/62462)) or customized builds out of scope of the standard and generic AArch64 support. That option set never supported the Raspberry Pi 4 family of devices.
+1
nixos/modules/module-list.nix
··· 981 981 ./services/networking/nix-serve.nix 982 982 ./services/networking/nix-store-gcs-proxy.nix 983 983 ./services/networking/nixops-dns.nix 984 + ./services/networking/nncp.nix 984 985 ./services/networking/nntp-proxy.nix 985 986 ./services/networking/nomad.nix 986 987 ./services/networking/nsd.nix
+131
nixos/modules/services/networking/nncp.nix
··· 1 + { config, lib, pkgs, ... }: 2 + with lib; 3 + 4 + let 5 + nncpCfgFile = "/run/nncp.hjson"; 6 + programCfg = config.programs.nncp; 7 + callerCfg = config.services.nncp.caller; 8 + daemonCfg = config.services.nncp.daemon; 9 + settingsFormat = pkgs.formats.json { }; 10 + jsonCfgFile = settingsFormat.generate "nncp.json" programCfg.settings; 11 + pkg = programCfg.package; 12 + in { 13 + options = { 14 + 15 + services.nncp = { 16 + caller = { 17 + enable = mkEnableOption '' 18 + cron'ed NNCP TCP daemon caller. 19 + The daemon will take configuration from 20 + [](#opt-programs.nncp.settings) 21 + ''; 22 + extraArgs = mkOption { 23 + type = with types; listOf str; 24 + description = "Extra command-line arguments to pass to caller."; 25 + default = [ ]; 26 + example = [ "-autotoss" ]; 27 + }; 28 + }; 29 + 30 + daemon = { 31 + enable = mkEnableOption '' 32 + NNCP TCP synronization daemon. 33 + The daemon will take configuration from 34 + [](#opt-programs.nncp.settings) 35 + ''; 36 + socketActivation = { 37 + enable = mkEnableOption '' 38 + Whether to run nncp-daemon persistently or socket-activated. 39 + ''; 40 + listenStreams = mkOption { 41 + type = with types; listOf str; 42 + description = lib.mdDoc '' 43 + TCP sockets to bind to. 44 + See [](#opt-systemd.sockets._name_.listenStreams). 45 + ''; 46 + default = [ "5400" ]; 47 + }; 48 + }; 49 + extraArgs = mkOption { 50 + type = with types; listOf str; 51 + description = "Extra command-line arguments to pass to daemon."; 52 + default = [ ]; 53 + example = [ "-autotoss" ]; 54 + }; 55 + }; 56 + 57 + }; 58 + }; 59 + 60 + config = mkIf (programCfg.enable or callerCfg.enable or daemonCfg.enable) { 61 + 62 + assertions = [{ 63 + assertion = with builtins; 64 + let 65 + callerCongfigured = 66 + let neigh = config.programs.nncp.settings.neigh or { }; 67 + in lib.lists.any (x: hasAttr "calls" x && x.calls != [ ]) 68 + (attrValues neigh); 69 + in !callerCfg.enable || callerCongfigured; 70 + message = "NNCP caller enabled but call configuration is missing"; 71 + }]; 72 + 73 + systemd.services."nncp-caller" = { 74 + inherit (callerCfg) enable; 75 + description = "Croned NNCP TCP daemon caller."; 76 + documentation = [ "http://www.nncpgo.org/nncp_002dcaller.html" ]; 77 + after = [ "network.target" ]; 78 + wantedBy = [ "multi-user.target" ]; 79 + serviceConfig = { 80 + ExecStart = '' 81 + ${pkg}/bin/nncp-caller -noprogress -cfg "${nncpCfgFile}" ${ 82 + lib.strings.escapeShellArgs callerCfg.extraArgs 83 + }''; 84 + Group = "uucp"; 85 + UMask = "0002"; 86 + }; 87 + }; 88 + 89 + systemd.services."nncp-daemon" = mkIf daemonCfg.enable { 90 + enable = !daemonCfg.socketActivation.enable; 91 + description = "NNCP TCP syncronization daemon."; 92 + documentation = [ "http://www.nncpgo.org/nncp_002ddaemon.html" ]; 93 + after = [ "network.target" ]; 94 + wantedBy = [ "multi-user.target" ]; 95 + serviceConfig = { 96 + ExecStart = '' 97 + ${pkg}/bin/nncp-daemon -noprogress -cfg "${nncpCfgFile}" ${ 98 + lib.strings.escapeShellArgs daemonCfg.extraArgs 99 + }''; 100 + Restart = "on-failure"; 101 + Group = "uucp"; 102 + UMask = "0002"; 103 + }; 104 + }; 105 + 106 + systemd.services."nncp-daemon@" = mkIf daemonCfg.socketActivation.enable { 107 + description = "NNCP TCP syncronization daemon."; 108 + documentation = [ "http://www.nncpgo.org/nncp_002ddaemon.html" ]; 109 + after = [ "network.target" ]; 110 + serviceConfig = { 111 + ExecStart = '' 112 + ${pkg}/bin/nncp-daemon -noprogress -ucspi -cfg "${nncpCfgFile}" ${ 113 + lib.strings.escapeShellArgs daemonCfg.extraArgs 114 + }''; 115 + Group = "uucp"; 116 + UMask = "0002"; 117 + StandardInput = "socket"; 118 + StandardOutput = "inherit"; 119 + StandardError = "journal"; 120 + }; 121 + }; 122 + 123 + systemd.sockets.nncp-daemon = mkIf daemonCfg.socketActivation.enable { 124 + inherit (daemonCfg.socketActivation) listenStreams; 125 + description = "socket for NNCP TCP syncronization."; 126 + conflicts = [ "nncp-daemon.service" ]; 127 + wantedBy = [ "sockets.target" ]; 128 + socketConfig.Accept = true; 129 + }; 130 + }; 131 + }