Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a28bcd7775 | |||
| 5c6a46df2f |
@@ -46,11 +46,11 @@ in {
|
|||||||
port = 8080;
|
port = 8080;
|
||||||
secret = name;
|
secret = name;
|
||||||
extraEnv = {
|
extraEnv = {
|
||||||
SESSION_SECRET_KEY = "7b0024c13ae770000f797c201e2f210b9932a689c04d34de04379faa44e88e97";
|
|
||||||
DATABASE_URL = "/db/sqlite.db";
|
DATABASE_URL = "/db/sqlite.db";
|
||||||
|
DEFAULT_INFLUX_SERVER = "http://${builder.host}:8181";
|
||||||
};
|
};
|
||||||
overrides = {
|
overrides = {
|
||||||
ports = [ "8080:8080" ];
|
ports = [ "8888:8080" ];
|
||||||
cmd = [ "--mode=admin" ];
|
cmd = [ "--mode=admin" ];
|
||||||
volumes = [
|
volumes = [
|
||||||
"${serverCfg.path.data}/influxdb:/db:rw"
|
"${serverCfg.path.data}/influxdb:/db:rw"
|
||||||
@@ -63,11 +63,11 @@ in {
|
|||||||
setup = {
|
setup = {
|
||||||
trigger = "server";
|
trigger = "server";
|
||||||
script = pkgs.writeShellScript "setup" ''
|
script = pkgs.writeShellScript "setup" ''
|
||||||
cat > ${serverCfg.path.config}/influxdb/config.json << 'EOF'
|
cat > ${serverCfg.path.config}/influxdb/config/config.json << 'EOF'
|
||||||
{
|
{
|
||||||
"DEFAULT_INFLUX_SERVER": "http://${builder.host}:8181",
|
"DEFAULT_INFLUX_SERVER": "http://${builder.host}:8181",
|
||||||
"DEFAULT_INFLUX_DATABASE": "main",
|
"DEFAULT_INFLUX_DATABASE": "main",
|
||||||
"DEFAULT_API_TOKEN": "$INFLUXDB3_TOKEN",
|
"DEFAULT_API_TOKEN": "$INFLUXDB_TOKEN",
|
||||||
"DEFAULT_SERVER_NAME": "${serverCfg.domain}"
|
"DEFAULT_SERVER_NAME": "${serverCfg.domain}"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
@@ -5,6 +5,23 @@ let
|
|||||||
listNames = config.syscfg.server.db;
|
listNames = config.syscfg.server.db;
|
||||||
containerNames = lib.concatMap (app: app.requires.databases) (builtins.attrValues config.syscfg.server.loadedContainers);
|
containerNames = lib.concatMap (app: app.requires.databases) (builtins.attrValues config.syscfg.server.loadedContainers);
|
||||||
allApps = lib.unique (listNames ++ containerNames);
|
allApps = lib.unique (listNames ++ containerNames);
|
||||||
|
influxAdminTokenJson = pkgs.writeShellScript "influxdb3-admin-token-json" ''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
token="''${INFLUXDB_TOKEN-''${INFLUXDB_TOKEN-}}"
|
||||||
|
if [ -z "$token" ]; then
|
||||||
|
echo "Missing INFLUXDB_TOKEN or INFLUXDB_TOKEN in ${config.sops.secrets."INFLUX".path}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > "$RUNTIME_DIRECTORY/admin-token.json" <<EOF
|
||||||
|
{
|
||||||
|
"token": "$token",
|
||||||
|
"name": "admin",
|
||||||
|
"description": "Admin token for automated deployment"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
in {
|
in {
|
||||||
config = lib.mkIf ( builtins.length allApps > 0) {
|
config = lib.mkIf ( builtins.length allApps > 0) {
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
@@ -53,7 +70,10 @@ in {
|
|||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart = "${pkgs.influxdb3}/bin/influxdb3 serve"; #--admin-token-file=/run/secrets/admin-token
|
EnvironmentFile = config.sops.secrets."INFLUX".path;
|
||||||
|
RuntimeDirectory = "influxdb3";
|
||||||
|
ExecStartPre = influxAdminTokenJson;
|
||||||
|
ExecStart = "${pkgs.influxdb3}/bin/influxdb3 serve --admin-token-file=%t/influxdb3/admin-token.json";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
StateDirectory = "influxdb3";
|
StateDirectory = "influxdb3";
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
@@ -61,12 +81,6 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# admin-token.json= {
|
|
||||||
# "token": "$INFLUXDB_TOKEN",
|
|
||||||
# "name": "admin",
|
|
||||||
# "description": "Admin token for automated deployment"
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
systemd.services.postgresql-init = {
|
systemd.services.postgresql-init = {
|
||||||
description = "Custom Postgres Setup (Ownership & Passwords)";
|
description = "Custom Postgres Setup (Ownership & Passwords)";
|
||||||
|
|||||||
Reference in New Issue
Block a user