summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorvolth <volth@webmaster.ms>2016-12-31 20:03:27 +0000
committerJörg Thalheim <joerg@higgsboson.tk>2016-12-31 21:03:27 +0100
commit06b372f24f20dd36cc2b120dbaf0347041fefed3 (patch)
tree91cd690ecdc44f44ad04e968ad39aa96ff43675b /nixos/modules/services
parent61027b7fcea9aef25b5a61700ccb21788365645f (diff)
downloadnixlib-06b372f24f20dd36cc2b120dbaf0347041fefed3.tar
nixlib-06b372f24f20dd36cc2b120dbaf0347041fefed3.tar.gz
nixlib-06b372f24f20dd36cc2b120dbaf0347041fefed3.tar.bz2
nixlib-06b372f24f20dd36cc2b120dbaf0347041fefed3.tar.lz
nixlib-06b372f24f20dd36cc2b120dbaf0347041fefed3.tar.xz
nixlib-06b372f24f20dd36cc2b120dbaf0347041fefed3.tar.zst
nixlib-06b372f24f20dd36cc2b120dbaf0347041fefed3.zip
miredo: init at 1.2.6
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/networking/miredo.nix93
1 files changed, 93 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/miredo.nix b/nixos/modules/services/networking/miredo.nix
new file mode 100644
index 000000000000..e4422e7f5b02
--- /dev/null
+++ b/nixos/modules/services/networking/miredo.nix
@@ -0,0 +1,93 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.miredo;
+  pidFile = "/run/miredo.pid";
+  miredoConf = pkgs.writeText "miredo.conf" ''
+    InterfaceName ${cfg.interfaceName}
+    ServerAddress ${cfg.serverAddress}
+    ${optionalString (cfg.bindAddress != null) "BindAddress ${cfg.bindAddress}"}
+    ${optionalString (cfg.bindPort != null) "BindPort ${cfg.bindPort}"}
+  '';
+in
+{
+
+  ###### interface
+
+  options = {
+
+    services.miredo = {
+
+      enable = mkEnableOption "Whether miredo should be run on startup.";
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.miredo;
+        defaultText = "pkgs.miredo";
+        description = ''
+          The package to use for the miredo daemon's binary.
+        '';
+      };
+
+      serverAddress = mkOption {
+        default = "teredo.remlab.net";
+        type = types.str;
+        description = ''
+          The hostname or primary IPv4 address of the Teredo server.
+          This setting is required if Miredo runs as a Teredo client.
+          "teredo.remlab.net" is an experimental service for testing only.
+          Please use another server for production and/or large scale deployments.
+        '';
+      };
+
+      interfaceName = mkOption {
+        default = "teredo";
+        type = types.str;
+        description = ''
+          Name of the network tunneling interface.
+        '';
+      };
+
+      bindAddress = mkOption {
+        default = null;
+        type = types.nullOr types.str;
+        description = ''
+          Depending on the local firewall/NAT rules, you might need to force
+          Miredo to use a fixed UDP port and or IPv4 address.
+        '';
+      };
+
+      bindPort = mkOption {
+        default = null;
+        type = types.nullOr types.str;
+        description = ''
+          Depending on the local firewall/NAT rules, you might need to force
+          Miredo to use a fixed UDP port and or IPv4 address.
+        '';
+      };
+    };
+  };
+
+
+  ###### implementation
+
+  config = mkIf cfg.enable {
+
+    systemd.services.miredo = {
+      wantedBy = [ "multi-user.target" ];
+      after = [ "network.target" ];
+      description = "Teredo IPv6 Tunneling Daemon";
+      serviceConfig = {
+        Restart = "always";
+        RestartSec = "5s";
+        ExecStartPre = "${cfg.package}/bin/miredo-checkconf -f ${miredoConf}";
+        ExecStart = "${cfg.package}/bin/miredo -c ${miredoConf} -p ${pidFile} -f";
+        ExecReload = "/bin/kill -HUP $MAINPID";
+      };
+    };
+
+  };
+
+}