nix: add extraConfig option

This commit adds a new option for joex and server modules - extraConfig.
Its main use-case is to specify options that are present in docspell but
not (perhaps, yet) defined in the modules.
This commit is contained in:
Vladimir Timofeenko 2022-12-12 08:25:21 -08:00
parent a7bc973345
commit f5a508be8d
3 changed files with 50 additions and 2 deletions

View File

@ -58,6 +58,16 @@ in
}
];
inherit full-text-search;
extraConfig = {
files = {
default-store = "database";
stores = {
minio = {
enabled = true;
};
};
};
};
};
environment.systemPackages =

View File

@ -3,10 +3,12 @@ overlay: { config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.docspell-joex;
# Extract the config without the extraConfig attribute. It will be merged later
declared_config = attrsets.filterAttrs (n: v: n != "extraConfig") cfg;
user = if cfg.runAs == null then "docspell" else cfg.runAs;
configFile = pkgs.writeText "docspell-joex.conf" ''
{"docspell": { "joex":
${builtins.toJSON cfg}
${builtins.toJSON (lib.recursiveUpdate declared_config cfg.extraConfig)}
}}
'';
defaults = {
@ -1670,6 +1672,23 @@ in
default = defaults.addons;
description = "Addon executor config";
};
extraConfig = mkOption {
type = types.attrs;
description = "Extra configuration for docspell server. Overwrites values in case of a conflict.";
default = { };
example = ''
{
files = {
default-store = "minio";
stores = {
minio = {
enabled = true;
};
};
};
}
'';
};
};
};

View File

@ -3,10 +3,12 @@ overlay: { config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.docspell-restserver;
# Extract the config without the extraConfig attribute. It will be merged later
declared_config = attrsets.filterAttrs (n: v: n != "extraConfig") cfg;
user = if cfg.runAs == null then "docspell" else cfg.runAs;
configFile = pkgs.writeText "docspell-server.conf" ''
{"docspell": {"server":
${builtins.toJSON cfg}
${builtins.toJSON (lib.recursiveUpdate declared_config cfg.extraConfig)}
}}
'';
defaults = {
@ -839,6 +841,23 @@ in
default = defaults.backend;
description = "Configuration for the backend";
};
extraConfig = mkOption {
type = types.attrs;
description = "Extra configuration for docspell server. Overwrites values in case of a conflict.";
default = { };
example = ''
{
files = {
default-store = "minio";
stores = {
minio = {
enabled = true;
};
};
};
}
'';
};
};
};