Files
samfelag/modules/server/nomad.nix
2024-02-11 20:58:26 +01:00

50 lines
1.3 KiB
Nix

{ config, lib, pkgs, self, ... }:
let
cfg = config.samfelag.modules.server.nomad;
in
{
options.samfelag.modules.server.nomad = {
enable = lib.mkEnableOption "nomad";
server = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set to true if configured a server - otherwise a client is assumed";
};
};
config = lib.mkIf cfg.enable {
# services.consul.enable = true;
services.nomad = {
enable = true;
extraSettingsPaths = [ "/etc/nomad.d" ];
};
environment.etc = {
# Common configuration
nomad-common-cfg = {
target = "nomad.d/common.json";
source = ../../config/nomad.d/common.json;
};
# Consul token
nomad-consul-token = {
target = "nomad.d/consul-token.json";
source = config.age.secrets."nomad.d/consul-token.json".path;
};
# Client configuration
nomad-client-cfg = {
target = "nomad.d/client.json";
source = ../../config/nomad.d/client.json;
};
} // lib.optionalAttrs cfg.server {
# Server configuration
nomad-server-cfg = {
target = "nomad.d/server.json";
source = ../../config/nomad.d/server.json;
};
};
# networking.firewall.allowedTCPPorts = [ 22 ];
};
}