from my phone so i cant see the changes lol
This commit is contained in:
108
modules/containers/gitea/container.nix
Normal file
108
modules/containers/gitea/container.nix
Normal file
@@ -0,0 +1,108 @@
|
||||
{moduleWithSystem, ...}: {
|
||||
flake.nixosModules.containerGitea = moduleWithSystem ({pkgs, ...}: {config, ...}: {
|
||||
virtualisation.oci-containers.containers."gitea" = {
|
||||
image = "docker.gitea.com/gitea:1.25.4";
|
||||
environment = {
|
||||
"GITEA__database__DB_TYPE" = "mysql";
|
||||
"GITEA__database__HOST" = "gitea-db:3306";
|
||||
"GITEA__database__NAME" = "gitea";
|
||||
"GITEA__database__USER" = "gitea";
|
||||
};
|
||||
environmentFiles = [config.sops.templates."gitea.env".path];
|
||||
volumes = [
|
||||
"/containers/gitea/gitea:/data:rw"
|
||||
"/etc/localtime:/etc/localtime:ro"
|
||||
"/etc/timezone:/etc/timezone:ro"
|
||||
];
|
||||
ports = [
|
||||
"3009:3000/tcp"
|
||||
"222:22/tcp"
|
||||
];
|
||||
dependsOn = [
|
||||
"gitea-db"
|
||||
];
|
||||
log-driver = "journald";
|
||||
extraOptions = [
|
||||
"--network-alias=server"
|
||||
"--network=gitea_gitea"
|
||||
];
|
||||
};
|
||||
systemd.services."podman-gitea" = {
|
||||
serviceConfig = {
|
||||
Restart = pkgs.lib.mkOverride 90 "always";
|
||||
};
|
||||
after = [
|
||||
"podman-network-gitea_gitea.service"
|
||||
];
|
||||
requires = [
|
||||
"podman-network-gitea_gitea.service"
|
||||
];
|
||||
partOf = [
|
||||
"podman-compose-gitea-root.target"
|
||||
];
|
||||
wantedBy = [
|
||||
"podman-compose-gitea-root.target"
|
||||
];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers."gitea-db" = {
|
||||
image = "docker.io/library/mysql:8";
|
||||
environment = {
|
||||
"MYSQL_DATABASE" = "gitea";
|
||||
# "MYSQL_PASSWORD" = config.sops.secrets."gitea-db-passwd";
|
||||
# "MYSQL_ROOT_PASSWORD" = config.sops.secrets."gitea-db-passwd";
|
||||
"MYSQL_USER" = "gitea";
|
||||
};
|
||||
environmentFiles = [config.sops.templates."gitea.env".path];
|
||||
extraOptions = [
|
||||
"--network-alias=db"
|
||||
"--network=gitea_gitea"
|
||||
];
|
||||
volumes = [
|
||||
"/containers/gitea/mysql:/var/lib/mysql:rw"
|
||||
];
|
||||
};
|
||||
systemd.services."podman-gitea-db" = {
|
||||
serviceConfig = {
|
||||
Restart = pkgs.lib.mkOverride 90 "always";
|
||||
};
|
||||
after = [
|
||||
"podman-network-gitea_gitea.service"
|
||||
];
|
||||
requires = [
|
||||
"podman-network-gitea_gitea.service"
|
||||
];
|
||||
partOf = [
|
||||
"podman-compose-gitea-root.target"
|
||||
];
|
||||
wantedBy = [
|
||||
"podman-compose-gitea-root.target"
|
||||
];
|
||||
};
|
||||
|
||||
# Networks
|
||||
systemd.services."podman-network-gitea_gitea" = {
|
||||
path = [pkgs.podman];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStop = "podman network rm -f gitea_gitea";
|
||||
};
|
||||
script = ''
|
||||
podman network inspect gitea_gitea || podman network create gitea_gitea
|
||||
'';
|
||||
partOf = ["podman-compose-gitea-root.target"];
|
||||
wantedBy = ["podman-compose-gitea-root.target"];
|
||||
};
|
||||
|
||||
# Root service
|
||||
# When started, this will automatically create all resources and start
|
||||
# the containers. When stopped, this will teardown all resources.
|
||||
systemd.targets."podman-compose-gitea-root" = {
|
||||
unitConfig = {
|
||||
Description = "Root target generated by compose2nix.";
|
||||
};
|
||||
wantedBy = ["multi-user.target"];
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user