add dbUrl

This commit is contained in:
zack 2024-10-21 19:52:48 -04:00
parent 748f956361
commit d6db331166
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35

View file

@ -69,6 +69,18 @@
description = "The phoenix package containing the application";
};
secret_key_file = mkOption {
type = types.string;
example = "/var/lib/skey";
description = "The Secrert key for Phoenix";
};
dbUrl = mkOption {
type = types.string;
default = "postgresql://${config.services.postgres.user}:${config.services.postgres.password}@${config.services.postgres.host}:${toString config.services.postgres.port}/zoeyscomputer_prod";
description = "Postgres Databaase URL";
};
enableServer = mkOption rec {
type = types.bool;
default = true;
@ -105,6 +117,7 @@
PORT = "${toString cfg.phx.port}";
PHX_HOST = cfg.domain;
PHX_SERVER = toString cfg.phx.enableServer;
DATABASE_URL = cfg.phx.dbUrl;
};
serviceConfig = {
Type = "exec";
@ -113,6 +126,7 @@
# Implied by DynamicUser, but just to emphasize due to RELEASE_TMP
PrivateTmp = true;
ExecStart = pkgs.writeShellScript "start-zoeycomputer" ''
export SECRET_KEY_BASE=$(cat ${cfg.phx.secret_key_file})
${cfg.phx.package}/bin/${release_name} eval "ZoeysComputer.Release.migrate"
${cfg.phx.package}/bin/${release_name} start
'';
@ -128,7 +142,7 @@
StartLimitInterval = 10;
};
# disksup requires bash
path = [pkgs.bash];
path = [pkgs.bash pkgs.coreutils];
};
};
};