modules/pleroma.nix: handle configuration from the module.

co-authored-by: duponin <duponin@locahlo.st>
This commit is contained in:
Félix Baylac-Jacqué 2020-11-03 21:34:03 +01:00
parent 75ef83fc3c
commit c57445a010
Signed by: picnoir
GPG Key ID: EFD315F31848DBA4
1 changed files with 32 additions and 0 deletions

View File

@ -23,10 +23,37 @@ in {
default = "pleroma";
description = "Group account under which pleroma runs.";
};
configs = mkOption {
type = with types; listOf str;
description = "TODO";
default = ''
'';
};
secretConfigFile = mkOption {
type = types.str;
default = "/var/lib/pleroma/secrets.exs";
description = "Path to the file containing your secret pleroma configuration.";
};
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = (builtins.length cfg.configs) > 0;
message = ''
This is a brand new installation. In that case you can use
`pleroma_ctl instance gen --output config.exs --output-psql setup.psql`,
this will prompt you some questions and will generate both your
config file and database initial migration. Note: `pleroma_ctl`
will be in your system path as soon as you enable the pleroma
service. You can alternatively build it by building this repo's
`default.nix` derivation.
'';
}
];
users = {
users."${cfg.user}" = {
description = "Pleroma user";
@ -38,6 +65,11 @@ in {
environment.systemPackages = [ cfg.package ];
environment.etc."/pleroma/config.exs" = ''
${lib.concatMapStrings (x: "${x}") cfg.configs}
include "${cfg.secretConfigFile}"
'';
systemd.services.pleroma = {
description = "Pleroma social network";
after = [ "network-online.target" "postgresql.service" ];