mirror of
https://github.com/zhaofengli/attic.git
synced 2024-12-14 11:57:30 +00:00
nixos: Allow settings to be omitted with null
This allows for suppressing the default database.url setting in the NixOS module. In the future, we need to rethink about the precedence of configuration sources. It makes sense for the environment variables to take precedence over configuration files.
This commit is contained in:
parent
79b0ad0553
commit
9c5e603e4b
1 changed files with 15 additions and 2 deletions
|
@ -15,6 +15,9 @@ let
|
|||
overlay = flake.defaultNix.overlays.default;
|
||||
|
||||
format = pkgs.formats.toml { };
|
||||
filteredSettings = lib.converge
|
||||
(lib.filterAttrsRecursive (_: v: ! lib.elem v [{ } null]))
|
||||
cfg.settings;
|
||||
|
||||
checkedConfigFile =
|
||||
pkgs.runCommand "checked-attic-server.toml"
|
||||
|
@ -113,7 +116,17 @@ in
|
|||
description = ''
|
||||
Structured configurations of atticd.
|
||||
'';
|
||||
type = format.type;
|
||||
type = let
|
||||
valueType = with types; nullOr (oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
path
|
||||
(attrsOf valueType)
|
||||
(listOf valueType)
|
||||
]);
|
||||
in types.attrsOf valueType;
|
||||
default = { }; # setting defaults here does not compose well
|
||||
};
|
||||
|
||||
|
@ -124,7 +137,7 @@ in
|
|||
By default, it's generated from `services.atticd.settings`.
|
||||
'';
|
||||
type = types.path;
|
||||
default = format.generate "server.toml" cfg.settings;
|
||||
default = format.generate "server.toml" filteredSettings;
|
||||
defaultText = "generated from `services.atticd.settings`";
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue