From c57445a010b9dba37c9c7f7766cbdaad3513ecc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= Date: Tue, 3 Nov 2020 21:34:03 +0100 Subject: [PATCH] modules/pleroma.nix: handle configuration from the module. co-authored-by: duponin --- modules/pleroma.nix | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/pleroma.nix b/modules/pleroma.nix index 7cb6f2e..986e93e 100644 --- a/modules/pleroma.nix +++ b/modules/pleroma.nix @@ -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" ];