i2pd: added package, service

This commit is contained in:
Edward Tjörnhammar 2014-11-09 09:44:47 +01:00
parent 08f66013ae
commit c329e5bbd9
5 changed files with 229 additions and 1 deletions

View File

@ -157,6 +157,7 @@
redmine = 147;
seeks = 148;
prosody = 149;
i2pd = 150;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
@ -281,6 +282,7 @@
redmine = 147;
seeks = 148;
prosody = 149;
i2pd = 150;
# When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399!

View File

@ -110,7 +110,7 @@
./services/databases/monetdb.nix
./services/databases/mongodb.nix
./services/databases/mysql.nix
./services/databases/neo4j.nix
./services/databases/neo4j.nix
./services/databases/openldap.nix
./services/databases/postgresql.nix
./services/databases/redis.nix
@ -230,6 +230,7 @@
./services/networking/gvpe.nix
./services/networking/haproxy.nix
./services/networking/hostapd.nix
./services/networking/i2pd.nix
./services/networking/ifplugd.nix
./services/networking/iodined.nix
./services/networking/ircd-hybrid/default.nix

View File

@ -0,0 +1,198 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.i2pd;
homeDir = "/var/lib/i2pd";
extip = "EXTIP=$(${pkgs.curl}/bin/curl -sf "http://jsonip.com" | ${pkgs.gawk}/bin/awk -F'\"' '{print $4}')";
i2pSh = pkgs.writeScriptBin "i2pd" ''
#!/bin/sh
${if isNull cfg.extIp then extip else ""}
${pkgs.i2pd}/bin/i2p --log=1 --daemon=0 --service=0 \
--v6=${if cfg.enableIPv6 then "1" else "0"} \
--unreachable=${if cfg.unreachable then "1" else "0"} \
--host=${if isNull cfg.extIp then "$EXTIP" else cfg.extIp} \
${if isNull cfg.port then "" else "--port=${toString cfg.port}"} \
--httpproxyport=${toString cfg.proxy.httpPort} \
--socksproxyport=${toString cfg.proxy.socksPort} \
--ircport=${toString cfg.irc.port} \
--ircdest=${cfg.irc.dest} \
--irckeys=${cfg.irc.keyFile} \
--eepport=${toString cfg.eep.port} \
${if isNull cfg.sam.port then "" else "--samport=${toString cfg.sam.port}"} \
--eephost=${cfg.eep.host} \
--eepkeys=${cfg.eep.keyFile}
'';
in
{
###### interface
options = {
services.i2pd = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Enables I2Pd as a running service upon activation.
'';
};
extIp = mkOption {
type = with types; nullOr str;
default = null;
description = ''
Your external IP.
'';
};
unreachable = mkOption {
type = types.bool;
default = false;
description = ''
If the router is declared to be unreachable and needs introduction nodes.
'';
};
port = mkOption {
type = with types; nullOr int;
default = null;
description = ''
I2P listen port. If no one is given the router will pick between 9111 and 30777.
'';
};
enableIPv6 = mkOption {
type = types.bool;
default = false;
description = ''
Enables IPv6 connectivity. Disabled by default.
'';
};
http = {
port = mkOption {
type = types.int;
default = 7070;
description = ''
HTTP listen port.
'';
};
};
proxy = {
httpPort = mkOption {
type = types.int;
default = 4446;
description = ''
HTTP proxy listen port.
'';
};
socksPort = mkOption {
type = types.int;
default = 4447;
description = ''
SOCKS proxy listen port.
'';
};
};
irc = {
dest = mkOption {
type = types.str;
default = "irc.postman.i2p";
description = ''
Destination I2P tunnel endpoint address of IRC server. irc.postman.i2p by default.
'';
};
port = mkOption {
type = types.int;
default = 6668;
description = ''
Local IRC tunnel endoint port to listen on. 6668 by default.
'';
};
keyFile = mkOption {
type = types.str;
default = "privKeys.dat";
description = ''
File name containing destination keys. privKeys.dat by default.
'';
};
};
eep = {
host = mkOption {
type = types.str;
default = "127.0.0.1";
description = ''
Address to forward incoming traffic to. 127.0.0.1 by default.
'';
};
port = mkOption {
type = types.int;
default = 80;
description = ''
Port to forward incoming trafic to. 80 by default.
'';
};
keyFile = mkOption {
type = types.str;
default = "privKeys.dat";
description = ''
File name containing destination keys. privKeys.dat by default.
'';
};
};
sam = {
port = mkOption {
type = with types; nullOr int;
default = null;
description = ''
Local SAM tunnel endpoint. Usually 7656. SAM is disabled if not specified.
'';
};
};
};
};
###### implementation
config = mkIf cfg.enable {
users.extraUsers.i2pd = {
group = "i2pd";
description = "I2Pd User";
home = homeDir;
createHome = true;
uid = config.ids.uids.i2pd;
};
users.extraGroups.i2pd.gid = config.ids.gids.i2pd;
systemd.services.i2pd = {
description = "Minimal I2P router";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig =
{
User = "i2pd";
WorkingDirectory = homeDir;
Restart = "on-abort";
ExecStart = "${i2pSh}/bin/i2pd";
};
};
};
}
#

View File

@ -0,0 +1,25 @@
{ stdenv, fetchurl, boost, cryptopp }:
stdenv.mkDerivation rec {
name = "i2pd-${version}";
version = "0.2.0";
src = fetchurl {
url = "https://github.com/PrivacySolutions/i2pd/archive/${version}.tar.gz";
sha256 = "0jr7svnwxiaxlxa3a8vcb8n6iy66ahwwx7glcwf2x57xssq27ily";
};
buildInputs = [ boost cryptopp ];
installPhase = ''
install -D i2p $out/bin/i2p
'';
meta = with stdenv.lib; {
homepage = "https://track.privacysolutions.no/projects/i2pd";
description = "Minimal I2P router written in C++";
licenses = licenses.gpl2;
maintainers = with maintainers; [ edwtjo ];
platform = platforms.linux;
};
}

View File

@ -1452,6 +1452,8 @@ let
httptunnel = callPackage ../tools/networking/httptunnel { };
i2pd = callPackage ../tools/networking/i2pd {};
iasl = callPackage ../development/compilers/iasl { };
icecast = callPackage ../servers/icecast { };