Commit 4c3842a
Changed files (3)
modules
hosts
cyrene
services
mobius
services
services
forgejo
modules/hosts/cyrene/services/default.nix
@@ -25,6 +25,11 @@
"ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-latest"
"nixos-latest:docker://git.trin.one/goi/nix-act-image:latest-x86_64-linux"
];
+ resourcesLimit = {
+ capacity = 1;
+ cpus = 1;
+ memory = "1g";
+ };
};
};
};
modules/hosts/mobius/services/default.nix
@@ -17,6 +17,11 @@
"nixos-latest:docker://git.trin.one/goi/nix-act-image:latest-x86_64-linux"
"nixos-latest-high:docker://git.trin.one/goi/nix-act-image:latest-x86_64-linux"
];
+ resourcesLimit = {
+ capacity = 2;
+ cpus = 2;
+ memory = "4g";
+ };
};
};
};
modules/services/forgejo/runner.nix
@@ -43,6 +43,23 @@
default = 4000;
description = "Port of the internal cache proxy. Must be unique per instance, as each runner binds it on the same host.";
};
+ resourcesLimit = {
+ capacity = lib.mkOption {
+ type = lib.types.ints.positive;
+ default = 1;
+ description = "Execute how many tasks concurrently at the same time.";
+ };
+ cpus = lib.mkOption {
+ type = lib.types.ints.positive;
+ default = 1;
+ description = "CPU cores usage limit per container";
+ };
+ memory = lib.mkOption {
+ type = lib.types.str;
+ default = "1g";
+ description = "Memory usage limit per container";
+ };
+ };
extraEnvironments = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = {};
@@ -98,7 +115,18 @@
settings = lib.mkMerge [
{
- runner.labels = lib.unique (instanceCfg.labels ++ (lib.concatLists (lib.mapAttrsToList (_: serverCfg: serverCfg.labels) instanceCfg.servers)));
+ runner = {
+ labels = lib.unique (
+ instanceCfg.labels
+ ++ (
+ lib.concatLists
+ (lib.mapAttrsToList
+ (_: serverCfg: serverCfg.labels)
+ instanceCfg.servers)
+ )
+ );
+ capacity = instanceCfg.resourcesLimit.capacity;
+ };
server.connections =
lib.mapAttrs (server: serverCfg: {
inherit (serverCfg) url uuid;
@@ -113,7 +141,13 @@
};
container = {
enable_ipv6 = true;
- options = "--cap-add sys_admin --cap-add mknod --device /dev/fuse";
+ options = lib.concatStringsSep " " [
+ "--cpus=${toString instanceCfg.resourcesLimit.cpus}"
+ "--memory=${toString instanceCfg.resourcesLimit.memory}"
+ "--cap-add sys_admin"
+ "--cap-add mknod"
+ "--device /dev/fuse"
+ ];
};
}
instanceCfg.extraSettings