1
1
Fork 0
nixos/options/custom/settings/containers/mastodon.nix
Myned ab485dec35
nix: format with alejandra
Signed-off-by: Myned <dev@bjork.tech>
2024-09-12 20:50:53 -05:00

62 lines
2 KiB
Nix

{
config,
inputs,
lib,
...
}:
with lib; let
cfg = config.custom.settings.containers.mastodon;
in {
options.custom.settings.containers.mastodon.enable = mkOption {default = false;};
config = mkIf cfg.enable {
age.secrets = let
secret = filename: {
file = "${inputs.self}/secrets/${filename}";
};
in {
"${config.custom.profile}/mastodon/.env" = secret "${config.custom.profile}/mastodon/.env";
"${config.custom.profile}/mastodon/db.env" = secret "${config.custom.profile}/mastodon/db.env";
};
#?? arion-mastodon pull
environment.shellAliases.arion-mastodon = "sudo arion --prebuilt-file ${config.virtualisation.arion.projects.mastodon.settings.out.dockerComposeYaml}";
virtualisation.arion.projects.mastodon = {
serviceName = "mastodon";
settings.services = {
# https://github.com/linuxserver/docker-mastodon
# https://github.com/mastodon/mastodon/blob/main/docker-compose.yml
mastodon.service = {
container_name = "mastodon";
env_file = [config.age.secrets."${config.custom.profile}/mastodon/.env".path];
image = "lscr.io/linuxserver/mastodon:4.2.12";
ports = ["3000:443"];
restart = "unless-stopped";
volumes = ["${config.custom.settings.containers.directory}/mastodon/config:/config"];
depends_on = [
"cache"
"db"
];
};
cache.service = {
container_name = "mastodon-cache";
image = "redis:latest";
restart = "unless-stopped";
volumes = ["${config.custom.settings.containers.directory}/mastodon/cache:/data"];
};
db.service = {
container_name = "mastodon-db";
env_file = [config.age.secrets."${config.custom.profile}/mastodon/db.env".path];
image = "postgres:15";
restart = "unless-stopped";
volumes = ["${config.custom.settings.containers.directory}/mastodon/db:/var/lib/postgresql/data"];
};
};
};
};
}