forked from DGNum/infrastructure
91 lines
1.8 KiB
Nix
91 lines
1.8 KiB
Nix
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
|
|
# SPDX-FileContributor: Elias Coppens <elias@dgnum.eu>
|
|
#
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
name,
|
|
...
|
|
}:
|
|
|
|
let
|
|
inherit (lib) mkEnableOption mkIf mkOption;
|
|
|
|
inherit (lib.types) int nullOr str;
|
|
|
|
cfg = config.dgn-forgejo-runners;
|
|
in
|
|
{
|
|
options.dgn-forgejo-runners = {
|
|
enable = mkEnableOption "forgejo-nix-runners for the DGNum forge";
|
|
|
|
nbRunners = mkOption {
|
|
type = int;
|
|
description = ''
|
|
Number of runners to spawn.
|
|
'';
|
|
};
|
|
|
|
nbCpus = mkOption {
|
|
type = nullOr int;
|
|
default = null;
|
|
description = ''
|
|
Maximum number of cores available for each runner.
|
|
When set to null, there will be no restriction.
|
|
'';
|
|
};
|
|
|
|
dataDirectory = mkOption {
|
|
type = str;
|
|
description = ''
|
|
Base directory to store data for runners.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.forgejo-nix-runners = {
|
|
enable = true;
|
|
|
|
url = "https://git.dgnum.eu";
|
|
|
|
storePath = cfg.dataDirectory;
|
|
tokenFile = config.age.secrets."forgejo_runners-token_file".path;
|
|
names = [
|
|
"on-${name}"
|
|
];
|
|
|
|
dependencies = [
|
|
pkgs.npins
|
|
pkgs.tea
|
|
];
|
|
|
|
containerOptions = lib.optional (cfg.nbCpus != null) "--cpus=${builtins.toString cfg.nbCpus}";
|
|
|
|
inherit (cfg) nbRunners;
|
|
};
|
|
|
|
virtualisation = {
|
|
podman = {
|
|
enable = true;
|
|
|
|
defaultNetwork.settings = {
|
|
dns_enable = true;
|
|
ipv6_enabled = true;
|
|
};
|
|
};
|
|
|
|
containers.storage.settings = {
|
|
storage = {
|
|
driver = "overlay";
|
|
graphroot = "${cfg.dataDirectory}/containers/storage";
|
|
runroot = "/run/containers/storage";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|