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.
- `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
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.

View file

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

View file

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