summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2014-05-17 16:44:27 -0500
committerAustin Seipp <aseipp@pobox.com>2014-05-17 16:44:27 -0500
commita0c6f07be4c58dfcf898de6f4a4ac7831f9409c0 (patch)
tree8843c9d13d15b2f371e0ee231cc42865572edac0 /nixos
parent3c8e1a9e47832e521560390cef5b889585e6a3f2 (diff)
parent08467c14deffcf33e0a1861c2dd50f7ebfd98852 (diff)
downloadnixlib-a0c6f07be4c58dfcf898de6f4a4ac7831f9409c0.tar
nixlib-a0c6f07be4c58dfcf898de6f4a4ac7831f9409c0.tar.gz
nixlib-a0c6f07be4c58dfcf898de6f4a4ac7831f9409c0.tar.bz2
nixlib-a0c6f07be4c58dfcf898de6f4a4ac7831f9409c0.tar.lz
nixlib-a0c6f07be4c58dfcf898de6f4a4ac7831f9409c0.tar.xz
nixlib-a0c6f07be4c58dfcf898de6f4a4ac7831f9409c0.tar.zst
nixlib-a0c6f07be4c58dfcf898de6f4a4ac7831f9409c0.zip
Merge pull request #2604 from wkennington/master.notbit
notbit: Bump version and add more configuration options
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/notbit.nix43
1 files changed, 40 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/notbit.nix b/nixos/modules/services/networking/notbit.nix
index b97435042395..3e8c956f191e 100644
--- a/nixos/modules/services/networking/notbit.nix
+++ b/nixos/modules/services/networking/notbit.nix
@@ -1,5 +1,6 @@
 { config, lib, pkgs, ... }:
 
+with pkgs.lib;
 let
   cfg = config.services.notbit;
   varDir = "/var/lib/notbit";
@@ -14,6 +15,10 @@ let
         --set XDG_RUNTIME_DIR ${varDir}
     '';
   };
+  opts = "${optionalString cfg.allowPrivateAddresses "-L"} ${optionalString cfg.noBootstrap "-b"} ${optionalString cfg.specifiedPeersOnly "-e"}";
+  peers = concatStringsSep " " (map (str: "-P \"${str}\"") cfg.peers);
+  listen = if cfg.listenAddress == [] then "-p ${toString cfg.port}" else
+    concatStringsSep " " (map (addr: "-a \"${addr}:${toString cfg.port}\"") cfg.listenAddress);
 in
 
 with lib;
@@ -35,7 +40,7 @@ with lib;
 
       port = mkOption {
         type = types.uniq types.int;
-        default = 8443;
+        default = 8444;
         description = "The port which the daemon listens for other bitmessage clients";
       };
 
@@ -45,6 +50,38 @@ with lib;
         description = "Set the nice level for the notbit daemon";
       };
 
+      listenAddress = mkOption {
+        type = types.listOf types.str;
+        default = [ ];
+        example = [ "localhost" "myhostname" ];
+        description = "The addresses which notbit will use to listen for incoming connections. These addresses are advertised to connecting clients.";
+      };
+
+      peers = mkOption {
+        type = types.listOf types.str;
+        default = [ ];
+        example = [ "bitmessage.org:8877" ];
+        description = "The initial set of peers notbit will connect to.";
+      };
+
+      specifiedPeersOnly = mkOption {
+        type = types.uniq types.bool;
+        default = false;
+        description = "If true, notbit will only connect to peers specified by the peers option.";
+      };
+
+      allowPrivateAddresses = mkOption {
+        type = types.uniq types.bool;
+        default = false;
+        description = "If true, notbit will allow connections to to RFC 1918 addresses.";
+      };
+
+      noBootstrap = mkOption {
+        type = types.uniq types.bool;
+        default = false;
+        description = "If true, notbit will not bootstrap an initial peerlist from bitmessage.org servers";
+      };
+
     };
 
   };
@@ -53,7 +90,7 @@ with lib;
 
   config = mkIf cfg.enable {
 
-    environment.systemPackages = [ pkgs.notbit sendmail ];
+    environment.systemPackages = [ sendmail ];
 
     systemd.services.notbit = {
       description = "Notbit daemon";
@@ -70,7 +107,7 @@ with lib;
 
       serviceConfig = {
         Type = "forking";
-        ExecStart = "${pkgs.notbit}/bin/notbit -d -p ${toString cfg.port}";
+        ExecStart = "${pkgs.notbit}/bin/notbit -d ${listen} ${peers} ${opts}";
         User = "notbit";
         Group = "notbit";
         UMask = "0077";