nixos/etebase-server: replace customIni with more flexible settings option
Fixes #112834 where incorrect documentation of options was reported. customIni used to replace the entire default configuration while the new settings option is merged in with the default configuration and still allows overriding options when needed.
This commit is contained in:
parent
933b6606ef
commit
dccd915adf
@ -8,31 +8,28 @@ let
|
|||||||
pythonEnv = pkgs.python3.withPackages (ps: with ps;
|
pythonEnv = pkgs.python3.withPackages (ps: with ps;
|
||||||
[ etebase-server daphne ]);
|
[ etebase-server daphne ]);
|
||||||
|
|
||||||
dbConfig = {
|
iniFmt = pkgs.formats.ini {};
|
||||||
sqlite3 = ''
|
|
||||||
engine = django.db.backends.sqlite3
|
|
||||||
name = ${cfg.dataDir}/db.sqlite3
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultConfigIni = toString (pkgs.writeText "etebase-server.ini" ''
|
configIni = iniFmt.generate "etebase-server.ini" cfg.settings;
|
||||||
[global]
|
|
||||||
debug = false
|
|
||||||
secret_file = ${if cfg.secretFile != null then cfg.secretFile else ""}
|
|
||||||
media_root = ${cfg.dataDir}/media
|
|
||||||
|
|
||||||
[allowed_hosts]
|
|
||||||
allowed_host1 = ${cfg.host}
|
|
||||||
|
|
||||||
[database]
|
|
||||||
${dbConfig."${cfg.database.type}"}
|
|
||||||
'');
|
|
||||||
|
|
||||||
configIni = if cfg.customIni != null then cfg.customIni else defaultConfigIni;
|
|
||||||
|
|
||||||
defaultUser = "etebase-server";
|
defaultUser = "etebase-server";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(mkRemovedOptionModule
|
||||||
|
[ "services" "etebase-server" "customIni" ]
|
||||||
|
"Set the option `services.etebase-server.settings' instead.")
|
||||||
|
(mkRemovedOptionModule
|
||||||
|
[ "services" "etebase-server" "database" ]
|
||||||
|
"Set the option `services.etebase-server.settings.database' instead.")
|
||||||
|
(mkRenamedOptionModule
|
||||||
|
[ "services" "etebase-server" "secretFile" ]
|
||||||
|
[ "services" "etebase-server" "settings" "secret_file" ])
|
||||||
|
(mkRenamedOptionModule
|
||||||
|
[ "services" "etebase-server" "host" ]
|
||||||
|
[ "services" "etebase-server" "settings" "allowed_hosts" "allowed_host1" ])
|
||||||
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.etebase-server = {
|
services.etebase-server = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
@ -42,21 +39,13 @@ in
|
|||||||
description = ''
|
description = ''
|
||||||
Whether to enable the Etebase server.
|
Whether to enable the Etebase server.
|
||||||
|
|
||||||
Once enabled you need to create an admin user using the
|
Once enabled you need to create an admin user by invoking the
|
||||||
shell command <literal>etebase-server createsuperuser</literal>.
|
shell command <literal>etebase-server createsuperuser</literal> with
|
||||||
|
the user specified by the <literal>user</literal> option or a superuser.
|
||||||
Then you can login and create accounts on your-etebase-server.com/admin
|
Then you can login and create accounts on your-etebase-server.com/admin
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
secretFile = mkOption {
|
|
||||||
default = null;
|
|
||||||
type = with types; nullOr str;
|
|
||||||
description = ''
|
|
||||||
The path to a file containing the secret
|
|
||||||
used as django's SECRET_KEY.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
dataDir = mkOption {
|
dataDir = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "/var/lib/etebase-server";
|
default = "/var/lib/etebase-server";
|
||||||
@ -77,15 +66,6 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
host = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "0.0.0.0";
|
|
||||||
example = "localhost";
|
|
||||||
description = ''
|
|
||||||
Host to listen on.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
unixSocket = mkOption {
|
unixSocket = mkOption {
|
||||||
type = with types; nullOr str;
|
type = with types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
@ -93,43 +73,76 @@ in
|
|||||||
example = "/run/etebase-server/etebase-server.sock";
|
example = "/run/etebase-server/etebase-server.sock";
|
||||||
};
|
};
|
||||||
|
|
||||||
database = {
|
settings = mkOption {
|
||||||
type = mkOption {
|
type = lib.types.submodule {
|
||||||
type = types.enum [ "sqlite3" ];
|
freeformType = iniFmt.type;
|
||||||
default = "sqlite3";
|
|
||||||
|
options = {
|
||||||
|
global = {
|
||||||
|
debug = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Database engine to use.
|
Whether to set django's DEBUG flag.
|
||||||
Currently only sqlite3 is supported.
|
|
||||||
Other options can be configured using <literal>extraConfig</literal>.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
secret_file = mkOption {
|
||||||
|
|
||||||
customIni = mkOption {
|
|
||||||
type = with types; nullOr str;
|
type = with types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Custom etebase-server.ini.
|
The path to a file containing the secret
|
||||||
|
used as django's SECRET_KEY.
|
||||||
See <literal>etebase-src/etebase-server.ini.example</literal> for available options.
|
|
||||||
|
|
||||||
Setting this option overrides the default config which is generated from the options
|
|
||||||
<literal>secretFile</literal>, <literal>host</literal> and <literal>database</literal>.
|
|
||||||
'';
|
'';
|
||||||
example = literalExample ''
|
};
|
||||||
[global]
|
media_root = mkOption {
|
||||||
debug = false
|
type = types.str;
|
||||||
secret_file = /path/to/secret
|
default = "${cfg.dataDir}/media";
|
||||||
media_root = /path/to/media
|
defaultText = "\${config.services.etebase-server.dataDir}/media";
|
||||||
|
description = "The media directory.";
|
||||||
[allowed_hosts]
|
};
|
||||||
allowed_host1 = example.com
|
};
|
||||||
|
allowed_hosts = {
|
||||||
[database]
|
allowed_host1 = mkOption {
|
||||||
engine = django.db.backends.sqlite3
|
type = types.str;
|
||||||
name = db.sqlite3
|
default = "0.0.0.0";
|
||||||
|
example = "localhost";
|
||||||
|
description = ''
|
||||||
|
The main host that is allowed access.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
database = {
|
||||||
|
engine = mkOption {
|
||||||
|
type = types.enum [ "django.db.backends.sqlite3" "django.db.backends.postgresql" ];
|
||||||
|
default = "django.db.backends.sqlite3";
|
||||||
|
description = "The database engine to use.";
|
||||||
|
};
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "${cfg.dataDir}/db.sqlite3";
|
||||||
|
defaultText = "\${config.services.etebase-server.dataDir}/db.sqlite3";
|
||||||
|
description = "The database name.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Configuration for <package>etebase-server</package>. Refer to
|
||||||
|
<link xlink:href="https://github.com/etesync/server/blob/master/etebase-server.ini.example" />
|
||||||
|
and <link xlink:href="https://github.com/etesync/server/wiki" />
|
||||||
|
for details on supported values.
|
||||||
|
'';
|
||||||
|
example = {
|
||||||
|
global = {
|
||||||
|
debug = true;
|
||||||
|
media_root = "/path/to/media";
|
||||||
|
};
|
||||||
|
allowed_hosts = {
|
||||||
|
allowed_host2 = "localhost";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
@ -166,8 +179,8 @@ in
|
|||||||
WorkingDirectory = cfg.dataDir;
|
WorkingDirectory = cfg.dataDir;
|
||||||
};
|
};
|
||||||
environment = {
|
environment = {
|
||||||
PYTHONPATH="${pythonEnv}/${pkgs.python3.sitePackages}";
|
PYTHONPATH = "${pythonEnv}/${pkgs.python3.sitePackages}";
|
||||||
ETEBASE_EASY_CONFIG_PATH="${configIni}";
|
ETEBASE_EASY_CONFIG_PATH = "${configIni}";
|
||||||
};
|
};
|
||||||
preStart = ''
|
preStart = ''
|
||||||
# Auto-migrate on first run or if the package has changed
|
# Auto-migrate on first run or if the package has changed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user