From 3c957bd921e792988cd9029b6037fc57a0ddcdd7 Mon Sep 17 00:00:00 2001 From: Mathijs Kwik Date: Sun, 4 Mar 2012 12:58:22 +0000 Subject: [PATCH] gogoclient: ipv6 tunnel module meant to replace the obsolete gw6c module builds fine on stdenv-updates branch svn path=/nixos/trunk/; revision=32767 --- modules/module-list.nix | 1 + modules/services/networking/gogoclient.nix | 88 ++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 modules/services/networking/gogoclient.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index 17bc561da803..7d42571d0fa6 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -121,6 +121,7 @@ ./services/networking/flashpolicyd.nix ./services/networking/git-daemon.nix ./services/networking/gnunet.nix + ./services/networking/gogoclient.nix ./services/networking/gvpe.nix ./services/networking/gw6c/default.nix ./services/networking/ifplugd.nix diff --git a/modules/services/networking/gogoclient.nix b/modules/services/networking/gogoclient.nix new file mode 100644 index 000000000000..19d3f5dd7559 --- /dev/null +++ b/modules/services/networking/gogoclient.nix @@ -0,0 +1,88 @@ +{pkgs, config, ...}: + +with pkgs.lib; + +let cfg = config.services.gogoclient; +in + +{ + + ###### interface + + options = { + services.gogoclient = { + enable = mkOption { + default = false; + type = types.bool; + description = '' + Enable the gogoclient ipv6 tunnel. + ''; + }; + autorun = mkOption { + default = true; + description = " + Switch to false to create upstart-job and configuration, + but not run it automatically + "; + }; + + username = mkOption { + default = ""; + description = " + Your Gateway6 login name, if any. + "; + }; + + password = mkOption { + default = ""; + type = types.string; + description = " + Path to a file (as a string), containing your gogonet password, if any. + "; + }; + + server = mkOption { + default = "anonymous.freenet6.net"; + example = "broker.freenet6.net"; + description = " + Used Gateway6 server. + "; + }; + }; + }; + + ###### implementation + + config = mkIf cfg.enable { + boot.kernelModules = [ "tun" ]; + + # environment.systemPackages = [pkgs.gogoclient]; + + networking = { + enableIPv6 = true; + interfaceJobs = optional cfg.autorun config.jobs.gogoclient; + }; + + jobs.gogoclient = { + name = "gogoclient"; + description = "ipv6 tunnel"; + startOn = if cfg.autorun then "started network-interfaces" else ""; + stopOn = "stopping network-interfaces"; + script = "cd /var/lib/gogoc; exec gogoc -y -f /etc/gogoc.conf"; + path = [pkgs.gogoclient]; + }; + + system.activationScripts.gogoClientConf = '' + mkdir -p /var/lib/gogoc + chmod 700 /var/lib/gogoc + install -m400 ${pkgs.gogoclient}/share/${pkgs.gogoclient.name}/gogoc.conf.sample /etc/gogoc.conf.default + ${pkgs.gnused}/bin/sed -i -e "s|^userid=|&${cfg.username}|" /etc/gogoc.conf.default + ${pkgs.gnused}/bin/sed -i -e "s|^passwd=|&${if cfg.password == "" then "" else "$(cat ${cfg.password})"}|" /etc/gogoc.conf.default + ${pkgs.gnused}/bin/sed -i -e "s|^server=.*|server=${cfg.server}|" /etc/gogoc.conf.default + ${pkgs.gnused}/bin/sed -i -e "s|^auth_method=.*|auth_method=${if cfg.password == "" then "anonymous" else "any"}|" /etc/gogoc.conf.default + ${pkgs.gnused}/bin/sed -i -e "s|^#log_file=|log_file=1|" /etc/gogoc.conf.default + mv /etc/gogoc.conf.default /etc/gogoc.conf + ''; + }; + +}