fix nixos modules

This commit is contained in:
tuxcoder 2023-12-17 15:31:19 +01:00
parent 5a26d53106
commit 4b1de43d43

View file

@ -16,7 +16,7 @@ in
username = mkOption {
type = lib.types.str;
description = mdDoc "user to run the service";
example = "lenticular_cloud";
default = "lenticular_cloud";
};
service_domain = mkOption {
type = lib.types.str;
@ -52,7 +52,7 @@ in
};
SQLALCHEMY_DATABASE_URI = mkOption {
type = types.str;
default = "postgresql://${username}@/${username}?host=/run/postgresql";
default = "postgresql://${cfg.username}@/${cfg.username}?host=/run/postgresql";
};
HYDRA_ADMIN_URL = mkOption {
type = types.str;
@ -75,26 +75,26 @@ in
];
users = {
groups."${username}" = {
groups."${cfg.username}" = {
};
users."${username}" = {
users."${cfg.username}" = {
createHome = true;
home = "/var/lib/${username}";
home = "/var/lib/${cfg.username}";
description = "web server";
extraGroups = [
# "ory-hydra"
];
group = username;
group = cfg.username;
isSystemUser = true;
};
};
services.postgresql = {
enable = true;
ensureDatabases = [ username ];
ensureDatabases = [ cfg.username ];
ensureUsers = [
{
name = username;
name = cfg.username;
ensureDBOwnership = true;
}
];
@ -116,10 +116,10 @@ in
serverName = cfg.service_domain;
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://unix:/run/${username}/web.sock";
proxyPass = "http://unix:/run/${cfg.username}/web.sock";
};
};
users.users.nginx.extraGroups = [ username ];
users.users.nginx.extraGroups = [ cfg.username ];
systemd.services.lenticular-cloud = {
description = "lenticular account";
@ -137,7 +137,7 @@ in
# PYTHONPATH = "${lenticular-pkg.pythonPath}:${lenticular-pkg}/lib/python3.10/site-packages:${python_path}";
};
preStart = ''
#cat > ${data_folder}/foobar.conf <<EOF
#cat > ${cfg.settings.DATA_FOLDER}/foobar.conf <<EOF
#SECRET_KEY=""
#EOF
${pkgs.lenticular-cloud}/bin/lenticular_cloud-cli db_upgrade
@ -145,14 +145,14 @@ in
serviceConfig = {
Type = "simple";
WorkingDirectory = data_folder;
User = username;
WorkingDirectory = cfg.settings.DATA_FOLDER;
User = cfg.username;
ExecStart = ''${python.pkgs.gunicorn}/bin/gunicorn lenticular_cloud.wsgi --name lenticular_cloud \
--workers 1 --log-level=info \
--bind=unix:/run/${username}/web.sock \
--bind=unix:/run/${cfg.username}/web.sock \
-k gevent'';
Restart = "on-failure";
RuntimeDirectory = username;
RuntimeDirectory = cfg.username;
};
};