summaryrefslogtreecommitdiff
path: root/src/Math/Perlin.hpp
AgeCommit message (Collapse)Author
2023-07-08Use own size typesMel
2023-06-29Pretty terrain generationMel
2023-06-12Multithreaded world generation with PerlinMel
{ pkgs, unstablePkgs, auxiliaryPkgs, ... }:

let
  inherit (pkgs) fedifetcher dockerTools;
  inherit (auxiliaryPkgs) common;

  akkomaLocalPort = 1111;
  akkomaDir = "/srv/akkoma";

  akkoma = unstablePkgs.akkoma.overrideAttrs {
    patches = [ ./docker-entrypoint.patch ];
    postInstall = ''
      cp docker-entrypoint.sh $out/docker-entrypoint.sh
    '';
  };

  akkomaImage = dockerTools.streamLayeredImage {
    name = "akkoma";
    tag = akkoma.version;
    fromImage = common.alpine.base;

    contents = with unstablePkgs; [
      exiftool imagemagick ffmpeg_7-headless postgresql elixir
    ] ++ [ akkoma ];

    extraCommands = ''
      mkdir -p opt/akkoma
    '';
  };

  fedifetcherScript = pkgs.writeShellScriptBin "fedifetcher-script.sh" ''
    fedifetcher -c /etc/fedifetcher/config.json &>> /var/log/fedifetcher.log
  '';

  fedifetcherCron = pkgs.writeText "fedifetcher-cron" ''
    0 */3 * * * /bin/fedifetcher-script.sh
  '';

  fedifetcherEntry = pkgs.writeShellScriptBin "fedifetcher-entry.sh" ''
    crond -b -l 0 -L /var/log/crond.log
    touch /var/log/fedifetcher.log
    tail -f /var/log/fedifetcher.log
  '';

  fedifetcherImage = dockerTools.streamLayeredImage {
    name = "fedifetcher";
    tag = fedifetcher.version;
    fromImage = common.alpine.base;

    contents = [ pkgs.bash fedifetcher fedifetcherEntry fedifetcherScript ];

    extraCommands = ''
      mkdir -p etc/crontabs
      cat ${fedifetcherCron} > etc/crontabs/root
    '';
  };

in
{
  foundation.service.akkoma = {
    akkoma = {
      image = akkomaImage;
      ports = [ [ akkomaLocalPort 4000 ] ];

      volumes = [
        [ "${akkomaDir}/data" "/var/lib/akkoma" ]
        [ "${akkomaDir}/config" "/opt/akkoma/config" ]
      ];

      # TODO: remove redundant variables
      environment = {
        "RUNTIME_DIRECTORY" = "/opt/akkoma";
        "AKKOMA_CONFIG_PATH" = "/opt/akkoma/config/config.exs";
        "RELEASE_COOKIE" = "99ff9ca022574585269e737cdc4fa28b";
        "RELEASE_NAME" = "akkoma";
        "MIX_ENV" = "prod";
        "DB_NAME" = "akkoma";
        "DB_USER" = "akkoma";
        "DB_PASS" = "akkoma";
        "DB_HOST" = "db";
      };

      entrypoint = "${akkoma}/docker-entrypoint.sh";
      workdir = "${akkoma}";
    };

    db = {
      fullImage = common.postgres14;

      volumes = [ [ "${akkomaDir}/pgdata" "/var/lib/postgresql/data" ] ];

      environment = {
        "POSTGRES_DB" = "akkoma";
        "POSTGRES_USER" = "akkoma";
        "POSTGRES_PASSWORD" = "akkoma";
      };
    };

    fedifetcher = {
      image = fedifetcherImage;

      volumes = [
        [ "${akkomaDir}/fedifetcher" "/opt/fedifetcher" ]
        [ "${akkomaDir}/fedifetcher.json" "/etc/fedifetcher/config.json" ]
      ];

      entrypoint = "/bin/fedifetcher-entry.sh";
    };
  };

  services.nginx.virtualHosts."soc.rnrd.eu" = {
    useACMEHost = "rnrd.eu";
    forceSSL = true;

    locations."/" = {
      proxyWebsockets = true;
      proxyPass = "http://127.0.0.1:${toString akkomaLocalPort}";
    };

    extraConfig = ''
      access_log /var/log/nginx/akkoma.access.log json_combined;
    '';
  };
}