mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 14:10:33 +03:00
nixos/ncdns: Replace custom config format handling with pkgs.formats.toml
This commit is contained in:
parent
7a2e88f7c1
commit
adaee656c2
1 changed files with 3 additions and 19 deletions
|
@ -6,23 +6,7 @@ let
|
|||
dataDir = "/var/lib/ncdns";
|
||||
username = "ncdns";
|
||||
|
||||
valueType = with lib.types; oneOf [ int str bool path ]
|
||||
// { description = "setting type (integer, string, bool or path)"; };
|
||||
|
||||
configType = with lib.types; attrsOf (nullOr (either valueType configType))
|
||||
// { description = ''
|
||||
ncdns.conf configuration type. The format consists of an
|
||||
attribute set of settings. Each setting can be either `null`,
|
||||
a value or an attribute set. The allowed values are integers,
|
||||
strings, booleans or paths.
|
||||
'';
|
||||
};
|
||||
|
||||
configFile = pkgs.runCommand "ncdns.conf"
|
||||
{ json = builtins.toJSON cfg.settings;
|
||||
passAsFile = [ "json" ];
|
||||
}
|
||||
"${pkgs.remarshal}/bin/json2toml < $jsonPath > $out";
|
||||
format = pkgs.formats.toml {};
|
||||
|
||||
defaultFiles = {
|
||||
public = "${dataDir}/bit.key";
|
||||
|
@ -160,7 +144,7 @@ in
|
|||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = configType;
|
||||
type = format.type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{ # enable webserver
|
||||
|
@ -257,7 +241,7 @@ in
|
|||
User = "ncdns";
|
||||
StateDirectory = "ncdns";
|
||||
Restart = "on-failure";
|
||||
ExecStart = "${pkgs.ncdns}/bin/ncdns -conf=${configFile}";
|
||||
ExecStart = "${pkgs.ncdns}/bin/ncdns -conf=${format.generate "ncdns.conf" cfg.settings}";
|
||||
};
|
||||
|
||||
preStart = lib.optionalString (cfg.dnssec.enable && needsKeygen) ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue