2012-03-04 12:58:22 +00:00
|
|
|
{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];
|
|
|
|
|
2012-03-04 18:44:47 +00:00
|
|
|
networking.enableIPv6 = true;
|
2012-03-04 12:58:22 +00:00
|
|
|
|
|
|
|
jobs.gogoclient = {
|
|
|
|
name = "gogoclient";
|
|
|
|
description = "ipv6 tunnel";
|
2012-03-04 18:44:47 +00:00
|
|
|
startOn = optionalString cfg.autorun "starting networking";
|
2012-03-04 12:58:22 +00:00
|
|
|
stopOn = "stopping network-interfaces";
|
2012-07-31 19:00:58 +01:00
|
|
|
preStart = ''
|
|
|
|
mkdir -p /var/lib/gogoc
|
|
|
|
chmod 700 /var/lib/gogoc
|
|
|
|
cat ${pkgs.gogoclient}/share/${pkgs.gogoclient.name}/gogoc.conf.sample | ${pkgs.gnused}/bin/sed -e "s|^userid=|&${cfg.username}|;s|^passwd=|&${if cfg.password == "" then "" else "$(cat ${cfg.password})"}|;s|^server=.*|server=${cfg.server}|;s|^auth_method=.*|auth_method=${if cfg.password == "" then "anonymous" else "any"}|;s|^#log_file=|log_file=1|" > /var/lib/gogoc/gogoc.conf
|
|
|
|
'';
|
|
|
|
script = "cd /var/lib/gogoc; exec gogoc -y -f ./gogoc.conf";
|
2012-03-04 12:58:22 +00:00
|
|
|
path = [pkgs.gogoclient];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|