2009-09-27 00:04:43 +01:00
|
|
|
{servicesPath, pkgs, config, ...}:
|
2009-03-06 12:25:48 +00:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption mkIf;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
gw6c = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable Gateway6 client (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 = "";
|
|
|
|
description = "
|
|
|
|
Your Gateway6 password, if any.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
server = mkOption {
|
|
|
|
default = "anon.freenet6.net";
|
|
|
|
example = "broker.freenet6.net";
|
|
|
|
description = "
|
|
|
|
Used Gateway6 server.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
keepAlive = mkOption {
|
|
|
|
default = "30";
|
|
|
|
example = "2";
|
|
|
|
description = "
|
|
|
|
Gateway6 keep-alive period.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
everPing = mkOption {
|
|
|
|
default = "1000000";
|
|
|
|
example = "2";
|
|
|
|
description = "
|
|
|
|
Gateway6 manual ping period.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
waitPingableBroker = mkOption {
|
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
description = "
|
|
|
|
Whether to wait until tunnel broker returns ICMP echo.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
security = {
|
|
|
|
seccureKeys = {
|
|
|
|
public = mkOption {
|
|
|
|
default = /var/elliptic-keys/public;
|
|
|
|
description = "
|
|
|
|
Public key. Make it path argument, so it is copied into store and
|
|
|
|
hashed.
|
|
|
|
|
|
|
|
The key is used to encrypt Gateway 6 configuration in store, as it
|
|
|
|
contains a password for external service. Unfortunately,
|
|
|
|
derivation file should be protected by other means. For example,
|
|
|
|
nix-http-export.cgi will happily export any non-derivation path,
|
|
|
|
but not a derivation.
|
|
|
|
";
|
|
|
|
};
|
2009-09-27 00:04:43 +01:00
|
|
|
|
2009-03-06 12:25:48 +00:00
|
|
|
private = mkOption {
|
|
|
|
default = "/var/elliptic-keys/private";
|
|
|
|
description = "
|
|
|
|
Private key. Make it string argument, so it is not copied into store.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2007-07-09 12:21:04 +01:00
|
|
|
let
|
2008-07-23 15:13:27 +01:00
|
|
|
cfg = config.services.gw6c;
|
|
|
|
procps = pkgs.procps;
|
2009-09-27 00:04:43 +01:00
|
|
|
gw6cService = import (servicesPath + /gw6c) {
|
2008-07-23 15:13:27 +01:00
|
|
|
inherit (pkgs) stdenv gw6c coreutils
|
|
|
|
procps upstart iputils gnused
|
2009-05-18 12:36:01 +01:00
|
|
|
gnugrep seccure writeScript;
|
2008-07-23 15:13:27 +01:00
|
|
|
username = cfg.username;
|
|
|
|
password = cfg.password;
|
|
|
|
server = cfg.server;
|
|
|
|
keepAlive = cfg.keepAlive;
|
|
|
|
everPing = cfg.everPing;
|
2008-03-04 16:06:33 +00:00
|
|
|
|
2008-07-23 15:13:27 +01:00
|
|
|
seccureKeys = config.security.seccureKeys;
|
2008-04-08 22:41:01 +01:00
|
|
|
|
2008-07-23 15:13:27 +01:00
|
|
|
waitPingableBroker = cfg.waitPingableBroker;
|
|
|
|
};
|
2007-07-09 12:21:04 +01:00
|
|
|
in
|
2009-03-06 12:25:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
mkIf config.services.gw6c.enable {
|
|
|
|
require = [
|
|
|
|
options
|
|
|
|
];
|
|
|
|
|
|
|
|
services = {
|
|
|
|
extraJobs = [{
|
2008-07-23 15:13:27 +01:00
|
|
|
name = "gw6c";
|
|
|
|
users = [];
|
|
|
|
groups = [];
|
2009-03-06 12:25:48 +00:00
|
|
|
job = ''
|
|
|
|
description \"Gateway6 client\"
|
2007-07-09 12:21:04 +01:00
|
|
|
|
2009-03-06 12:25:48 +00:00
|
|
|
start on ${ if cfg.autorun then "network-interfaces/started" else "never" }
|
|
|
|
stop on network-interfaces/stop
|
2007-07-09 12:21:04 +01:00
|
|
|
|
2009-03-06 12:25:48 +00:00
|
|
|
respawn ${gw6cService}/bin/control start
|
|
|
|
'';
|
|
|
|
}];
|
|
|
|
};
|
2007-07-09 12:21:04 +01:00
|
|
|
}
|