summaryrefslogtreecommitdiff
path: root/services/akkoma
diff options
context:
space:
mode:
Diffstat (limited to 'services/akkoma')
-rw-r--r--services/akkoma/default.nix91
1 files changed, 16 insertions, 75 deletions
diff --git a/services/akkoma/default.nix b/services/akkoma/default.nix
index 8b89df7..939e9be 100644
--- a/services/akkoma/default.nix
+++ b/services/akkoma/default.nix
@@ -1,11 +1,11 @@
-{ lib, pkgs, unstablePkgs, auxiliaryPkgs, ... }:
+{ pkgs, unstablePkgs, auxiliaryPkgs, ... }:
let
inherit (pkgs) dockerTools;
inherit (auxiliaryPkgs) common;
inherit (unstablePkgs) fedifetcher;
- akkomaLocalPort = "1111";
+ akkomaLocalPort = 1111;
akkomaDir = "/srv/akkoma";
akkoma = unstablePkgs.akkoma.overrideAttrs {
@@ -15,7 +15,7 @@ let
'';
};
- akkomaImage = dockerTools.buildLayeredImage {
+ akkomaImage = dockerTools.streamLayeredImage {
name = "akkoma";
tag = akkoma.version;
fromImage = common.alpine.base;
@@ -43,7 +43,7 @@ let
tail -f /var/log/fedifetcher.log
'';
- fedifetcherImage = dockerTools.buildLayeredImage {
+ fedifetcherImage = dockerTools.streamLayeredImage {
name = "fedifetcher";
tag = fedifetcher.version;
fromImage = common.alpine.base;
@@ -58,15 +58,14 @@ let
in
{
- virtualisation.oci-containers.containers = {
+ foundation.service.akkoma = {
akkoma = {
- imageFile = akkomaImage;
- image = "akkoma:${akkoma.version}";
- ports = [ "127.0.0.1:${akkomaLocalPort}:4000"];
+ image = akkomaImage;
+ ports = [ [ akkomaLocalPort 4000 ] ];
volumes = [
- "${akkomaDir}/data:/var/lib/akkoma"
- "${akkomaDir}/config:/opt/akkoma/config"
+ [ "${akkomaDir}/data" "/var/lib/akkoma" ]
+ [ "${akkomaDir}/config" "/opt/akkoma/config" ]
];
# TODO: remove redundant variables
@@ -84,87 +83,29 @@ in
entrypoint = "${akkoma}/docker-entrypoint.sh";
workdir = "${akkoma}";
-
- extraOptions = [
- "--network-alias=akkoma"
- "--network=akkoma"
- ];
};
- akkoma-db = {
- inherit (common.postgres14) image imageFile;
+ db = {
+ fullImage = common.postgres14;
- volumes = [ "${akkomaDir}/pgdata:/var/lib/postgresql/data" ];
+ volumes = [ [ "${akkomaDir}/pgdata" "/var/lib/postgresql/data" ] ];
environment = {
"POSTGRES_DB" = "akkoma";
"POSTGRES_USER" = "akkoma";
"POSTGRES_PASSWORD" = "akkoma";
};
-
- extraOptions = [
- "--network-alias=db"
- "--network=akkoma"
- ];
};
- akkoma-fedifetcher = {
- imageFile = fedifetcherImage;
- image = "fedifetcher:${fedifetcher.version}";
+ fedifetcher = {
+ image = fedifetcherImage;
volumes = [
- "${akkomaDir}/fedifetcher:/opt/fedifetcher"
- "${akkomaDir}/fedifetcher.json:/etc/fedifetcher/config.json"
+ [ "${akkomaDir}/fedifetcher" "/opt/fedifetcher" ]
+ [ "${akkomaDir}/fedifetcher.json" "/etc/fedifetcher/config.json" ]
];
entrypoint = "/bin/fedifetcher-entry.sh";
-
- extraOptions = [
- "--network-alias=db"
- "--network=akkoma"
- ];
- };
- };
-
- # systemd configuration to combine containers.
- # mostly condensed from compose2nix output.
- # TODO: make this automatic!!
- systemd = let
- root = "docker-akkoma-root";
- network = "docker-akkoma-network";
-
- containerService = {
- serviceConfig = {
- Restart = lib.mkOverride 90 "always";
- RestartMaxDelaySec = lib.mkOverride 90 "1m";
- RestartSec = lib.mkOverride 90 "100ms";
- RestartSteps = lib.mkOverride 90 9;
- };
- after = [ "${network}.service" ]; requires = [ "${network}.service" ];
- partOf = [ "${root}.target" ]; wantedBy = [ "${root}.target" ];
- };
- in {
- services = {
- "docker-akkoma" = containerService;
- "docker-akkoma-db" = containerService;
- "docker-akkoma-fedifetcher" = containerService;
-
- "${network}" = {
- path = [ pkgs.docker ];
- serviceConfig = {
- Type = "oneshot";
- RemainAfterExit = true;
- ExecStop = "docker network rm -f akkoma";
- };
- script = ''
- docker network inspect akkoma || docker network create akkoma --driver=bridge
- '';
- partOf = [ "${root}.target" ]; wantedBy = [ "${root}.target" ];
- };
- };
-
- targets = {
- "${root}" = { wantedBy = [ "multi-user.target" ]; };
};
};
}