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