Set an admin passwd

This commit is contained in:
niten 2023-07-17 19:54:33 -07:00
parent bb49e8c2e8
commit 5e2db3985b
1 changed files with 10 additions and 1 deletions

View File

@ -152,7 +152,8 @@ let
} }
''; '';
makeLemmyCfg = { hostname, postgresPasswd, pictrsApiKey, smtpServer, ... }: makeLemmyCfg = { hostname, postgresPasswd, pictrsApiKey, smtpServer
, adminPasswd ? null, ... }:
pkgs.writeText "lemmy.hjson" (builtins.toJSON { pkgs.writeText "lemmy.hjson" (builtins.toJSON {
database = { database = {
host = "postgres"; host = "postgres";
@ -168,6 +169,10 @@ let
tls_type = "none"; tls_type = "none";
smtp_from_address = "noreply@${hostname}"; smtp_from_address = "noreply@${hostname}";
}; };
setup = mkIf (adminPasswd != null) {
admin_username = "admin";
admin_password = adminPasswd;
};
}); });
postgresCfgFile = pkgs.writeText "lemmy-postgres.conf" '' postgresCfgFile = pkgs.writeText "lemmy-postgres.conf" ''
@ -265,6 +270,9 @@ in {
readFile (pkgs.lib.passwd.random-passwd-file "lemmy-postgres-passwd" 30); readFile (pkgs.lib.passwd.random-passwd-file "lemmy-postgres-passwd" 30);
pictrsApiKey = pictrsApiKey =
readFile (pkgs.lib.passwd.random-passwd-file "lemmy-pictrs-api-key" 30); readFile (pkgs.lib.passwd.random-passwd-file "lemmy-pictrs-api-key" 30);
adminPasswd = readFile
(pkgs.lib.passwd.stablerandom-passwd-file "lemmy-admin-passwd"
config.build.build-seed);
in { in {
fudo.secrets.host-secrets."${config.instance.hostname}" = { fudo.secrets.host-secrets."${config.instance.hostname}" = {
lemmyPictrsEnv = { lemmyPictrsEnv = {
@ -294,6 +302,7 @@ in {
inherit (cfg) hostname; inherit (cfg) hostname;
inherit postgresPasswd pictrsApiKey; inherit postgresPasswd pictrsApiKey;
smtpServer = cfg.smtp-server; smtpServer = cfg.smtp-server;
adminPasswd = adminPasswd;
}; };
target-file = "/run/lemmy/lemmy.hjson"; target-file = "/run/lemmy/lemmy.hjson";
}; };