nixos/corerad: use pkgs.formats.toml to generate TOML configuration
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
parent
09b571cfe7
commit
071c02a4b2
|
@ -4,13 +4,7 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.corerad;
|
cfg = config.services.corerad;
|
||||||
|
settingsFormat = pkgs.formats.toml {};
|
||||||
writeTOML = name: x:
|
|
||||||
pkgs.runCommandNoCCLocal name {
|
|
||||||
passAsFile = ["config"];
|
|
||||||
config = builtins.toJSON x;
|
|
||||||
buildInputs = [ pkgs.go-toml ];
|
|
||||||
} "jsontoml < $configPath > $out";
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = with maintainers; [ mdlayher ];
|
meta.maintainers = with maintainers; [ mdlayher ];
|
||||||
|
@ -19,7 +13,7 @@ in {
|
||||||
enable = mkEnableOption "CoreRAD IPv6 NDP RA daemon";
|
enable = mkEnableOption "CoreRAD IPv6 NDP RA daemon";
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = types.uniq types.attrs;
|
type = settingsFormat.type;
|
||||||
example = literalExample ''
|
example = literalExample ''
|
||||||
{
|
{
|
||||||
interfaces = [
|
interfaces = [
|
||||||
|
@ -64,7 +58,7 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
# Prefer the config file over settings if both are set.
|
# Prefer the config file over settings if both are set.
|
||||||
services.corerad.configFile = mkDefault (writeTOML "corerad.toml" cfg.settings);
|
services.corerad.configFile = mkDefault (settingsFormat.generate "corerad.toml" cfg.settings);
|
||||||
|
|
||||||
systemd.services.corerad = {
|
systemd.services.corerad = {
|
||||||
description = "CoreRAD IPv6 NDP RA daemon";
|
description = "CoreRAD IPv6 NDP RA daemon";
|
||||||
|
|
Loading…
Reference in New Issue