Skip to content

Commit

Permalink
cjdns service: better types
Browse files Browse the repository at this point in the history
- types.string -> str, string is deprecated
- change type of confFile option to nullOr path, makes more sense
  • Loading branch information
joachifm committed Oct 27, 2016
1 parent afe67f2 commit 5fba586
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions nixos/modules/services/networking/cjdns.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ in
};

confFile = mkOption {
type = types.str;
default = "";
type = types.nullOr types.path;
default = null;
example = "/etc/cjdroute.conf";
description = ''
Ignore all other cjdns options and load configuration from this file.
Expand All @@ -119,7 +119,7 @@ in

admin = {
bind = mkOption {
type = types.string;
type = types.str;
default = "127.0.0.1:11234";
description = ''
Bind the administration port to this address and port.
Expand All @@ -129,7 +129,7 @@ in

UDPInterface = {
bind = mkOption {
type = types.string;
type = types.str;
default = "";
example = "192.168.1.32:43211";
description = ''
Expand All @@ -154,6 +154,7 @@ in

ETHInterface = {
bind = mkOption {
type = types.str;
default = "";
example = "eth0";
description =
Expand Down Expand Up @@ -212,7 +213,7 @@ in
wantedBy = [ "multi-user.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
if [ -z "$CJDNS_PRIVATE_KEY" ]; then
Expand All @@ -234,7 +235,7 @@ in
'';

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
echo '${cjdrouteConf}' | sed \
Expand All @@ -253,7 +254,7 @@ in
networking.extraHosts = "${cjdnsHosts}";

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.";
}
{ assertion = config.networking.enableIPv6;
Expand Down

0 comments on commit 5fba586

Please sign in to comment.