cjdns service: better types

- types.string -> str, string is deprecated
- change type of confFile option to nullOr path, makes more sense
This commit is contained in:
Joachim Fasting 2016-10-24 20:32:43 +02:00
parent afe67f28a3
commit 5fba586650
1 changed files with 8 additions and 7 deletions

View File

@ -95,8 +95,8 @@ in
}; };
confFile = mkOption { confFile = mkOption {
type = types.str; type = types.nullOr types.path;
default = ""; default = null;
example = "/etc/cjdroute.conf"; example = "/etc/cjdroute.conf";
description = '' description = ''
Ignore all other cjdns options and load configuration from this file. Ignore all other cjdns options and load configuration from this file.
@ -119,7 +119,7 @@ in
admin = { admin = {
bind = mkOption { bind = mkOption {
type = types.string; type = types.str;
default = "127.0.0.1:11234"; default = "127.0.0.1:11234";
description = '' description = ''
Bind the administration port to this address and port. Bind the administration port to this address and port.
@ -129,7 +129,7 @@ in
UDPInterface = { UDPInterface = {
bind = mkOption { bind = mkOption {
type = types.string; type = types.str;
default = ""; default = "";
example = "192.168.1.32:43211"; example = "192.168.1.32:43211";
description = '' description = ''
@ -154,6 +154,7 @@ in
ETHInterface = { ETHInterface = {
bind = mkOption { bind = mkOption {
type = types.str;
default = ""; default = "";
example = "eth0"; example = "eth0";
description = description =
@ -212,7 +213,7 @@ in
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network.target" ]; after = [ "network.target" ];
preStart = if cfg.confFile != "" then "" else '' preStart = if cfg.confFile != null then "" else ''
[ -e /etc/cjdns.keys ] && source /etc/cjdns.keys [ -e /etc/cjdns.keys ] && source /etc/cjdns.keys
if [ -z "$CJDNS_PRIVATE_KEY" ]; then if [ -z "$CJDNS_PRIVATE_KEY" ]; then
@ -234,7 +235,7 @@ in
''; '';
script = ( script = (
if cfg.confFile != "" then "${pkg}/bin/cjdroute < ${cfg.confFile}" else if cfg.confFile != null then "${pkg}/bin/cjdroute < ${cfg.confFile}" else
'' ''
source /etc/cjdns.keys source /etc/cjdns.keys
echo '${cjdrouteConf}' | sed \ echo '${cjdrouteConf}' | sed \
@ -253,7 +254,7 @@ in
networking.extraHosts = "${cjdnsHosts}"; networking.extraHosts = "${cjdnsHosts}";
assertions = [ assertions = [
{ assertion = ( cfg.ETHInterface.bind != "" || cfg.UDPInterface.bind != "" || cfg.confFile != "" ); { assertion = ( cfg.ETHInterface.bind != "" || cfg.UDPInterface.bind != "" || cfg.confFile != null );
message = "Neither cjdns.ETHInterface.bind nor cjdns.UDPInterface.bind defined."; message = "Neither cjdns.ETHInterface.bind nor cjdns.UDPInterface.bind defined.";
} }
{ assertion = config.networking.enableIPv6; { assertion = config.networking.enableIPv6;