-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: porting mail and git to new server
- Loading branch information
Showing
6 changed files
with
256 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ config, pkgs, ... }: | ||
let | ||
secret-management = { | ||
owner = config.services.gitlab.user; | ||
}; | ||
in | ||
{ | ||
sops.secrets = { | ||
"git/db" = secret-management; | ||
"git/otp" = secret-management; | ||
"git/root" = secret-management; | ||
"git/secret" = secret-management; | ||
"git/database" = secret-management; | ||
"mail/users/git" = secret-management; | ||
}; | ||
|
||
services.gitlab = { | ||
enable = true; | ||
host = "gulag.uz"; | ||
databasePasswordFile = config.sops.secrets."git/database".path; | ||
initialRootPasswordFile = config.sops.secrets."git/root".path; | ||
secrets = { | ||
dbFile = config.sops.secrets."git/db".path; | ||
otpFile = config.sops.secrets."git/otp".path; | ||
secretFile = config.sops.secrets."git/secret".path; | ||
jwsFile = pkgs.runCommand "oidcKeyBase" { } "${pkgs.openssl}/bin/openssl genrsa 2048 > $out"; | ||
}; | ||
|
||
# Sending mail via Kolyma's SMTP | ||
smtp = { | ||
# Enabling smtp mailing | ||
enable = true; | ||
|
||
# Connection configuration | ||
tls = true; | ||
port = 465; | ||
authentication = "plain"; | ||
domain = "mail.kolyma.uz"; | ||
opensslVerifyMode = "none"; | ||
address = "mail.kolyma.uz"; | ||
enableStartTLSAuto = false; | ||
|
||
# Credentials for SMTP | ||
username = "git"; | ||
passwordFile = config.sops.secrets."mail/users/git".path; | ||
}; | ||
|
||
# Settings to be appended at gitlab.yml | ||
extraConfig = { | ||
gitlab = { | ||
email_from = "staff@kolyma.uz"; | ||
email_display_name = "Kolyma Git Administration"; | ||
email_reply_to = "noreply@kolyma.uz"; | ||
}; | ||
gitlab_shell = { | ||
ssh_port = 2222; | ||
}; | ||
}; | ||
}; | ||
|
||
# Enable web server & proxy | ||
services.www.hosts = { | ||
"gulag.uz" = { | ||
extraConfig = '' | ||
reverse_proxy unix//run/gitlab/gitlab-workhorse.socket | ||
''; | ||
}; | ||
}; | ||
|
||
systemd.services.gitlab-backup.environment.BACKUP = "dump"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
{ | ||
inputs, | ||
config, | ||
pkgs, | ||
... | ||
}: | ||
let | ||
secret-management = { | ||
owner = config.users.users.stalwart-mail.name; | ||
}; | ||
in | ||
{ | ||
sops.secrets = { | ||
"mail/acme" = secret-management; | ||
"mail/admin" = secret-management; | ||
"mail/public-cert" = secret-management; | ||
"mail/private-cert" = secret-management; | ||
"mail/users/git" = secret-management; | ||
"mail/users/sakhib" = secret-management; | ||
"mail/users/misskey" = secret-management; | ||
}; | ||
|
||
services.stalwart-mail = { | ||
enable = true; | ||
package = pkgs.stalwart-mail; | ||
openFirewall = true; | ||
|
||
settings = { | ||
server = { | ||
hostname = "mail.kolyma.uz"; | ||
|
||
tls = { | ||
enable = true; | ||
implicit = true; | ||
}; | ||
|
||
listener = { | ||
smtp = { | ||
protocol = "smtp"; | ||
bind = "[::]:25"; | ||
}; | ||
submission = { | ||
bind = "[::]:587"; | ||
protocol = "smtp"; | ||
}; | ||
submissions = { | ||
bind = "[::]:465"; | ||
protocol = "smtp"; | ||
tls.implicit = true; | ||
}; | ||
imap = { | ||
bind = "[::]:143"; | ||
protocol = "imap"; | ||
}; | ||
imaptls = { | ||
bind = "[::]:993"; | ||
protocol = "imap"; | ||
tls.implicit = true; | ||
}; | ||
pop3 = { | ||
bind = "[::]:110"; | ||
protocol = "pop3"; | ||
}; | ||
pop3s = { | ||
bind = "[::]:995"; | ||
protocol = "pop3"; | ||
tls.implicit = true; | ||
}; | ||
sieve = { | ||
bind = "[::]:4190"; | ||
protocol = "managesieve"; | ||
}; | ||
jmap = { | ||
bind = "[::]:8080"; | ||
url = "https://mail.kolyma.uz"; | ||
protocol = "http"; | ||
}; | ||
management = { | ||
bind = [ "127.0.0.1:8080" ]; | ||
protocol = "http"; | ||
}; | ||
}; | ||
}; | ||
|
||
lookup.default = { | ||
hostname = "mail.kolyma.uz"; | ||
domain = "kolyma.uz"; | ||
}; | ||
|
||
acme."letsencrypt" = { | ||
directory = "https://acme-v02.api.letsencrypt.org/directory"; | ||
challenge = "dns-01"; | ||
contact = "admin@kolyma.uz"; | ||
domains = [ | ||
"kolyma.uz" | ||
"mail.kolyma.uz" | ||
]; | ||
provider = "cloudflare"; | ||
secret = "%{file:${config.sops.secrets."mail/acme".path}}%"; | ||
}; | ||
|
||
certificate."default" = { | ||
cert = "%{file:${config.sops.secrets."mail/public-cert".path}}%"; | ||
private-key = "%{file:${config.sops.secrets."mail/private-cert".path}}%"; | ||
default = true; | ||
}; | ||
|
||
session.auth = { | ||
mechanisms = "[plain]"; | ||
directory = "'in-memory'"; | ||
}; | ||
|
||
storage.directory = "in-memory"; | ||
session.rcpt.directory = "'in-memory'"; | ||
queue.outbound.next-hop = "'local'"; | ||
directory."imap".lookup.domains = [ "kolyma.uz" ]; | ||
directory."in-memory" = { | ||
type = "memory"; | ||
principals = [ | ||
{ | ||
class = "individual"; | ||
name = "orzklv"; | ||
description = "Sokhibjon Orzikulov"; | ||
secret = "%{file:${config.sops.secrets."mail/users/sakhib".path}}%"; | ||
email = [ | ||
"orzklv@kolyma.uz" | ||
"admin@kolyma.uz" | ||
"postmaster@kolyma.uz" | ||
]; | ||
} | ||
]; | ||
}; | ||
|
||
authentication.fallback-admin = { | ||
user = "admin"; | ||
secret = "%{file:${config.sops.secrets."mail/admin".path}}%"; | ||
}; | ||
}; | ||
}; | ||
|
||
services.www.hosts = { | ||
"mail.kolyma.uz" = { | ||
extraConfig = '' | ||
reverse_proxy http://127.0.0.1:8080 | ||
''; | ||
serverAliases = [ | ||
"mta-sts.kolyma.uz" | ||
"autoconfig.kolyma.uz" | ||
"autodiscover.kolyma.uz" | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters