nixos/frp: use toml configFile

According to upstream, the INI configuration file is deprecated and
TOML/YAML/JSON is recommended.
Link: https://github.com/fatedier/frp/tree/dev#configuration-files
This commit is contained in:
Adithya Nair 2023-12-15 15:43:45 +05:30
parent aaae35a64e
commit 8b5644684e
No known key found for this signature in database
GPG key ID: 48FC9915FFD326D0
3 changed files with 27 additions and 26 deletions

View file

@ -67,6 +67,12 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
- The legacy and long deprecated systemd target `network-interfaces.target` has been removed. Use `network.target` instead. - The legacy and long deprecated systemd target `network-interfaces.target` has been removed. Use `network.target` instead.
- `services.frp.settings` now generates the frp configuration file in TOML format as [recommended by upstream](https://github.com/fatedier/frp#configuration-files), instead of the legacy INI format. This has also introduced other changes in the configuration file structure and options.
- The `settings.common` section in the configuration is no longer valid and all the options form inside it now goes directly under `settings`.
- The `_` separating words in the configuration options is removed so the options are now in camel case. For example: `server_addr` becomes `serverAddr`, `server_port` becomes `serverPort` etc.
- Proxies are now defined with a new option `settings.proxies` which takes a list of proxies.
- Consult the [upstream documentation](https://github.com/fatedier/frp#example-usage) for more details on the changes.
- `mkosi` was updated to v20. Parts of the user interface have changed. Consult the - `mkosi` was updated to v20. Parts of the user interface have changed. Consult the
release notes of [v19](https://github.com/systemd/mkosi/releases/tag/v19) and release notes of [v19](https://github.com/systemd/mkosi/releases/tag/v19) and
[v20](https://github.com/systemd/mkosi/releases/tag/v20) for a list of changes. [v20](https://github.com/systemd/mkosi/releases/tag/v20) for a list of changes.

View file

@ -4,8 +4,8 @@ with lib;
let let
cfg = config.services.frp; cfg = config.services.frp;
settingsFormat = pkgs.formats.ini { }; settingsFormat = pkgs.formats.toml { };
configFile = settingsFormat.generate "frp.ini" cfg.settings; configFile = settingsFormat.generate "frp.toml" cfg.settings;
isClient = (cfg.role == "client"); isClient = (cfg.role == "client");
isServer = (cfg.role == "server"); isServer = (cfg.role == "server");
in in
@ -31,17 +31,13 @@ in
default = { }; default = { };
description = mdDoc '' description = mdDoc ''
Frp configuration, for configuration options Frp configuration, for configuration options
see the example of [client](https://github.com/fatedier/frp/blob/dev/conf/frpc_legacy_full.ini) see the example of [client](https://github.com/fatedier/frp/blob/dev/conf/frpc_full_example.toml)
or [server](https://github.com/fatedier/frp/blob/dev/conf/frps_legacy_full.ini) on github. or [server](https://github.com/fatedier/frp/blob/dev/conf/frps_full_example.toml) on github.
''; '';
example = literalExpression '' example = {
{ serverAddr = "x.x.x.x";
common = { serverPort = 7000;
server_addr = "x.x.x.x";
server_port = 7000;
}; };
}
'';
}; };
}; };
}; };
@ -62,7 +58,7 @@ in
Type = "simple"; Type = "simple";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 15; RestartSec = 15;
ExecStart = "${cfg.package}/bin/${executableFile} -c ${configFile}"; ExecStart = "${cfg.package}/bin/${executableFile} --strict_config -c ${configFile}";
StateDirectoryMode = optionalString isServer "0700"; StateDirectoryMode = optionalString isServer "0700";
DynamicUser = true; DynamicUser = true;
# Hardening # Hardening

View file

@ -18,10 +18,8 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
enable = true; enable = true;
role = "server"; role = "server";
settings = { settings = {
common = { bindPort = 7000;
bind_port = 7000; vhostHTTPPort = 80;
vhost_http_port = 80;
};
}; };
}; };
}; };
@ -59,15 +57,16 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
enable = true; enable = true;
role = "client"; role = "client";
settings = { settings = {
common = { serverAddr = "10.0.0.1";
server_addr = "10.0.0.1"; serverPort = 7000;
server_port = 7000; proxies = [
}; {
web = { name = "web";
type = "http"; type = "http";
local_port = 80; localPort = 80;
custom_domains = "10.0.0.1"; customDomains = [ "10.0.0.1" ];
}; }
];
}; };
}; };
}; };