Compare commits

...

4 Commits

Author SHA1 Message Date
7212011e40
modules/rnsd: play with format a bit.. 2024-01-31 18:21:56 -07:00
5785a96042
Merge branch 'main' into reticulum 2024-01-31 06:02:39 -07:00
d54282b40d
modules/nomadne: init 2024-01-22 06:10:15 -07:00
0b32761492
modules/rnsd: init
- add md2mu (non-working)
- enable rnsd on h
2024-01-18 12:30:00 -07:00
7 changed files with 316 additions and 0 deletions

View File

@ -325,6 +325,9 @@
kobuddy = upkgs.python3Packages.callPackage ./pkgs/kobuddy.nix {
inherit upkgs;
};
md2mu = upkgs.python3Packages.callPackage ./pkgs/md2mu.nix {
inherit upkgs;
};
bandcamp-downloader = upkgs.python3Packages.callPackage ./pkgs/bandcamp-downloader.nix {
inherit upkgs;
};

View File

@ -180,6 +180,59 @@ in
services.xinCA = { enable = false; };
services = {
rnsd = {
enable = true;
settings = {
reticulum = {
enable_transport = true;
shared_instance = true;
shared_instance_port = 37428;
instance_control_port = 37429;
panic_on_interface_error = true;
};
logging = {
loglevel = 8;
};
interfaces = {
"Default Interface" = {
enabled = true;
type = "AutoInterface";
};
"RNS Testnet BetweenTheBorders" = {
enabled = true;
mode = "boundary";
target_host = "betweentheborders.com";
target_port = 4242;
type = "TCPClientInterface";
};
"RNode LoRa Interface" = {
bandwidth = 125000;
codingrate = 5;
enabled = false;
flow_control = false;
frequency = 915000000;
mode = "ap";
port = "/dev/ttyACM0";
spreadingfactor = 9;
txpower = 7;
type = "RNodeInterface";
};
"RNode BT LoRa Interface" = {
bandwidth = 125000;
codingrate = 5;
enabled = true;
flow_control = false;
frequency = 915000000;
mode = "ap";
port = "/dev/rfcomm0";
spreadingfactor = 9;
txpower = 7;
type = "RNodeInterface";
};
};
};
};
power-profiles-daemon.enable = false;
tlp = {
enable = true;

View File

@ -313,6 +313,45 @@ in
};
services = {
rnsd = {
enable = false;
settings = {
reticulum = {
enable_transport = true;
};
logging = {
loglevel = 4;
};
interfaces = {
"Default Interface" = {
type = "AutoInterface";
enabled = true;
};
"UDP Interface" = {
type = "UDPInterface";
enabled = true;
listen_ip = "0.0.0.0";
listen_port = 4242;
forward_ip = "255.255.255.255";
forward_port = 4242;
};
"TCP Interface" = {
type = "TCPServerInterface";
enabled = true;
listen_ip = "0.0.0.0";
listen_port = 4242;
forward_ip = "255.255.255.255";
forward_port = 4242;
};
"RNS Testnet BetweenTheBorders" = {
type = "TCPClientInterface";
enabled = true;
target_host = "betweentheborders.com";
target_port = 4242;
};
};
};
};
wallabag = {
enable = false;
secretPath = config.sops.secrets.wallabag_secret.path;

View File

@ -2,6 +2,8 @@
imports = [
./golink.nix
./gotosocial.nix
./nomadnet.nix
./rnsd.nix
./rtlamr2mqtt.nix
./sliding-sync.nix
./ssh-fido-agent.nix

84
modules/nomadnet.nix Normal file
View File

@ -0,0 +1,84 @@
{ lib
, config
, pkgs
, ...
}:
let
cfg = config.services.nomadnet;
defaultSettings = { };
settingsFormat = pkgs.formats.toml { };
settingsFile = settingsFormat.generate "config.toml" cfg.settings;
in
{
options = with lib; {
services.nomadnet = {
enable = lib.mkEnableOption "Enable nomadnet";
dataDir = mkOption {
type = types.path;
default = "/var/lib/nomadnet";
description = "Path nomadnet home directory";
};
user = mkOption {
type = with types; oneOf [ str int ];
default = "nomadnet";
description = ''
The user the service will use.
'';
};
group = mkOption {
type = with types; oneOf [ str int ];
default = "nomadnet";
description = ''
The group the service will use.
'';
};
package = mkOption {
type = types.package;
default = pkgs.python3Packages.nomadnet;
defaultText = literalExpression "pkgs.python3Packages.nomadnet";
description = "The package to use for nomadnet";
};
settings = lib.mkOption {
type = settingsFormat.type;
default = defaultSettings;
description = lib.mdDoc ''
run `nomadnet --exampleconfig` to see an example.
'';
};
};
};
config = lib.mkIf cfg.enable {
users.groups.${cfg.group} = { };
users.users.${cfg.user} = {
description = "nomadnet service user";
isSystemUser = true;
home = "${cfg.dataDir}";
createHome = true;
group = "${cfg.group}";
};
systemd.services.nomadnet = {
enable = true;
description = "nomadnet server";
wantedBy = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
#DynamicUser = true;
#User = "nomadnet";
#Group = "nomadnet";
#StateDirectory = "nomadnet";
#CacheDirectory = "nomadnet";
#LogsDirectory = "nomadnet";
#ProtectHome = true;
ExecStartPre = "${pkgs.coreutils}/bin/ln -sf ${settingsFile} ${cfg.dataDir}/config";
ExecStart = "${cfg.package}/bin/nomadnet -d --config ${cfg.dataDir}";
};
};
};
}

99
modules/rnsd.nix Normal file
View File

@ -0,0 +1,99 @@
{ lib
, config
, pkgs
, ...
}:
let
cfg = config.services.rnsd;
defaultSettings = { };
settingsFormat = pkgs.formats.json { };
settingsFile = settingsFormat.generate "rnsd-config.json" cfg.settings;
in
{
options = with lib; {
services.rnsd = {
enable = lib.mkEnableOption "Enable rnsd";
dataDir = mkOption {
type = types.path;
default = "/var/lib/rnsd";
description = "Path rnsd home directory";
};
user = mkOption {
type = with types; oneOf [ str int ];
default = "rnsd";
description = ''
The user the service will use.
'';
};
group = mkOption {
type = with types; oneOf [ str int ];
default = "rnsd";
description = ''
The group the service will use.
'';
};
package = mkOption {
type = types.package;
default = pkgs.python3Packages.rns;
defaultText = literalExpression "pkgs.python3Packages.rns";
description = "The package to use for rnsd";
};
settings = lib.mkOption {
type = settingsFormat.type;
default = defaultSettings;
description = lib.mdDoc ''
run `rnsd --exampleconfig` to see an example.
'';
};
#port = lib.mkOption {
# type = types.int;
# defautl = 4242;
# defaultText = "4242";
# description = "Port to use for establishing an isolated net";
#};
openFirewall = mkOption {
type = types.bool;
default = false;
description = "enable rnsd in the firewall";
};
};
};
config = lib.mkIf cfg.enable {
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ 4242 ];
allowedUDPPorts = [ 4242 ];
};
users.groups.${cfg.group} = { };
users.users.${cfg.user} = {
description = "rnsd service user";
isSystemUser = true;
home = "${cfg.dataDir}";
createHome = true;
group = "${cfg.group}";
extraGroups = [ "dialout" ];
};
systemd.services.rnsd = {
enable = true;
description = "rnsd server";
wantedBy = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
User = cfg.user;
Group = cfg.group;
ExecStartPre = "${pkgs.coreutils}/bin/ln -sf ${settingsFile} ${cfg.dataDir}/config";
ExecStart = "${cfg.package}/bin/rnsd -s -v --config ${cfg.dataDir}";
};
};
};
}

36
pkgs/md2mu.nix Normal file
View File

@ -0,0 +1,36 @@
{ lib
, fetchFromGitHub
, buildPythonPackage
#, fetchPypi
#, setuptools-scm
, mistune
#, alembic
#, banal
#, sqlalchemy
, ...
}:
buildPythonPackage rec {
pname = "md2mu";
version = "unstable-2023-05-16";
format = "setuptools";
src = fetchFromGitHub {
owner = "randogoth";
repo = pname;
rev = "baf662b97fde0b2456fb3da725f1caf14882d60e";
hash = "sha256-93fr1EV4UfRPq1MQSffoHtLvTYFQeaqHQ+BtsTlH8Ec=";
};
doCheck = true;
#nativeBuildInputs = [ setuptools-scm ];
propagatedBuildInputs = [ mistune ];
meta = with lib; {
homepage = "https://github.com/randogoth/md2mu";
description = "Markdown to micron converter";
license = licenses.mit;
maintainers = with maintainers; [ qbit ];
};
}