Skip to content

Commit

Permalink
planefinder: allow a services.planefinder.configFile option
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Jul 2, 2024
1 parent 8a0949e commit 87151ea
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions modules/planefinder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ let

mkConfigFile =
cfg:
pkgs.writeTextFile {
name = "planefinder-config.json";
text = ''
{
"tcp_address": "localhost",
"tcp_port": "30005",
"select_timeout": "10",
"data_upload_interval": "10",
"connection_type": "1",
"aircraft_timeout": "30",
"data_format": "1",
"sharecode": "${cfg.shareCode}",
"latitude": "${cfg.latitude}",
"longitude": "${cfg.longitude}"
}
'';
};
if cfg.configFile == null then
pkgs.writeTextFile {
name = "planefinder-config.json";
text = ''
{
"tcp_address": "localhost",
"tcp_port": "30005",
"select_timeout": "10",
"data_upload_interval": "10",
"connection_type": "1",
"aircraft_timeout": "30",
"data_format": "1",
"sharecode": "${cfg.shareCode}",
"latitude": "${cfg.latitude}",
"longitude": "${cfg.longitude}"
}
'';
}
else
cfg.configFile;
in
{
options = {
Expand All @@ -43,6 +46,17 @@ in
description = lib.mdDoc "Open ports in the firewall for planefinder.";
};

configFile = lib.mkOption {
default = null;
description = ''
Path to Planefinder config file.
Setting this option will override any configuration applied by
other configuration options.
'';
type = lib.types.nullOr lib.types.path;
};

shareCode = lib.mkOption {
type = lib.types.str;
default = "";
Expand Down

0 comments on commit 87151ea

Please sign in to comment.