diff --git a/flake.nix b/flake.nix index 0fca22d..1490fbc 100644 --- a/flake.nix +++ b/flake.nix @@ -324,6 +324,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; }; diff --git a/hosts/europa/default.nix b/hosts/europa/default.nix index aa85732..19130f6 100644 --- a/hosts/europa/default.nix +++ b/hosts/europa/default.nix @@ -180,6 +180,45 @@ in services.xinCA = { enable = false; }; 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; + }; + }; + }; + }; power-profiles-daemon.enable = false; tlp = { enable = true; diff --git a/hosts/h/default.nix b/hosts/h/default.nix index 7c66578..9ac2740 100644 --- a/hosts/h/default.nix +++ b/hosts/h/default.nix @@ -306,6 +306,45 @@ in }; services = { + rnsd = { + enable = true; + 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; diff --git a/modules/default.nix b/modules/default.nix index 1a88caa..7ce1847 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,6 +2,7 @@ imports = [ ./golink.nix ./gotosocial.nix + ./rnsd.nix ./rtlamr2mqtt.nix ./sliding-sync.nix ./ssh-fido-agent.nix diff --git a/modules/rnsd.nix b/modules/rnsd.nix new file mode 100644 index 0000000..d5360ba --- /dev/null +++ b/modules/rnsd.nix @@ -0,0 +1,96 @@ +{ lib +, config +, pkgs +, ... +}: +let + cfg = config.services.rnsd; + defaultSettings = { }; + settingsFormat = pkgs.formats.toml { }; + settingsFile = settingsFormat.generate "config.toml" 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. + ''; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + description = "enable veilid-server 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}"; + }; + systemd.services.rnsd = { + enable = true; + description = "rnsd server"; + wantedBy = [ "network-online.target" ]; + after = [ "network-online.target" ]; + + serviceConfig = { + #DynamicUser = true; + #User = "rnsd"; + #Group = "rnsd"; + #StateDirectory = "rnsd"; + #CacheDirectory = "rnsd"; + #LogsDirectory = "rnsd"; + #ProtectHome = true; + ExecStartPre = "${pkgs.coreutils}/bin/ln -sf ${settingsFile} ${cfg.dataDir}/config"; + ExecStart = "${cfg.package}/bin/rnsd -v --config ${cfg.dataDir}"; + }; + }; + }; +} diff --git a/pkgs/md2mu.nix b/pkgs/md2mu.nix new file mode 100644 index 0000000..0bf5175 --- /dev/null +++ b/pkgs/md2mu.nix @@ -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 ]; + }; +}