feat: add memory limit
This commit is contained in:
parent
c923126eff
commit
2c1316a0a6
3 changed files with 53 additions and 18 deletions
|
|
@ -5,6 +5,9 @@ in
|
||||||
rec {
|
rec {
|
||||||
continuwuity = {
|
continuwuity = {
|
||||||
port = 6167;
|
port = 6167;
|
||||||
|
server_name = "nudelerde.de";
|
||||||
|
trusted_servers = [ "matrix.org" ];
|
||||||
|
memory_max = "512M";
|
||||||
};
|
};
|
||||||
|
|
||||||
qbittorrent = {
|
qbittorrent = {
|
||||||
|
|
@ -25,10 +28,6 @@ rec {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
matrix = {
|
|
||||||
trusted_servers = [ "matrix.org" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
vikunja = {
|
vikunja = {
|
||||||
port = 8081;
|
port = 8081;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
net = import ../config/network.nix;
|
|
||||||
serv = import ../config/services.nix;
|
serv = import ../config/services.nix;
|
||||||
serviceValidation = import ../validation/service/continuwuity.nix;
|
serviceValidation = import ../validation/service/continuwuity.nix;
|
||||||
|
|
||||||
serverName =
|
serverName = serviceValidation.getServerName serv;
|
||||||
if net ? devices && builtins.isAttrs net.devices && net.devices ? remote_proxy && net.devices.remote_proxy ? domain && builtins.isString net.devices.remote_proxy.domain then
|
|
||||||
net.devices.remote_proxy.domain
|
|
||||||
else
|
|
||||||
throw "config/network.nix must define devices.remote_proxy.domain as string for continuwuity.";
|
|
||||||
|
|
||||||
trustedServers = serviceValidation.getTrustedServers serv;
|
trustedServers = serviceValidation.getTrustedServers serv;
|
||||||
|
memoryMax = serviceValidation.getMemoryMax serv;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.matrix-continuwuity = {
|
services.matrix-continuwuity = {
|
||||||
|
|
@ -27,4 +23,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.matrix-continuwuity.serviceConfig =
|
||||||
|
lib.optionalAttrs (memoryMax != null) {
|
||||||
|
MemoryMax = memoryMax;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,54 @@ let
|
||||||
common = import ./common.nix;
|
common = import ./common.nix;
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
|
getServerName = serviceData:
|
||||||
|
let
|
||||||
|
continuwuity =
|
||||||
|
if serviceData ? continuwuity then
|
||||||
|
common.ensureAttrset "config/services.nix continuwuity" serviceData.continuwuity
|
||||||
|
else
|
||||||
|
throw "config/services.nix must define continuwuity attrset.";
|
||||||
|
|
||||||
|
serverName =
|
||||||
|
if continuwuity ? server_name then
|
||||||
|
common.ensureString "config/services.nix continuwuity.server_name" continuwuity.server_name
|
||||||
|
else
|
||||||
|
throw "config/services.nix continuwuity.server_name must exist.";
|
||||||
|
in
|
||||||
|
if serverName != "" then
|
||||||
|
serverName
|
||||||
|
else
|
||||||
|
throw "config/services.nix continuwuity.server_name must be a non-empty string.";
|
||||||
|
|
||||||
getTrustedServers = serviceData:
|
getTrustedServers = serviceData:
|
||||||
let
|
let
|
||||||
matrix =
|
continuwuity =
|
||||||
if serviceData ? matrix then
|
if serviceData ? continuwuity then
|
||||||
common.ensureAttrset "config/services.nix matrix" serviceData.matrix
|
common.ensureAttrset "config/services.nix continuwuity" serviceData.continuwuity
|
||||||
else
|
else
|
||||||
throw "config/services.nix must define matrix attrset.";
|
throw "config/services.nix must define continuwuity attrset.";
|
||||||
|
|
||||||
trustedServers =
|
trustedServers =
|
||||||
if matrix ? trusted_servers then
|
if continuwuity ? trusted_servers then
|
||||||
common.ensureList "config/services.nix matrix.trusted_servers" matrix.trusted_servers
|
common.ensureList "config/services.nix continuwuity.trusted_servers" continuwuity.trusted_servers
|
||||||
else
|
else
|
||||||
throw "config/services.nix matrix.trusted_servers must exist.";
|
throw "config/services.nix continuwuity.trusted_servers must exist.";
|
||||||
in
|
in
|
||||||
trustedServers;
|
trustedServers;
|
||||||
|
|
||||||
|
getMemoryMax = serviceData:
|
||||||
|
let
|
||||||
|
continuwuity =
|
||||||
|
if serviceData ? continuwuity then
|
||||||
|
common.ensureAttrset "config/services.nix continuwuity" serviceData.continuwuity
|
||||||
|
else
|
||||||
|
throw "config/services.nix must define continuwuity attrset.";
|
||||||
|
in
|
||||||
|
if !(continuwuity ? memory_max) then
|
||||||
|
null
|
||||||
|
else
|
||||||
|
let
|
||||||
|
value = common.ensureString "config/services.nix continuwuity.memory_max" continuwuity.memory_max;
|
||||||
|
in
|
||||||
|
if value != "" then value else throw "config/services.nix continuwuity.memory_max must be a non-empty string when provided.";
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue