first pass
This commit is contained in:
commit
7822529a38
31 files changed
+7050
No files matched your search
@@ -0,0 +1,55 @@
|
||||
self:
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.slackspawn;
|
||||
in
|
||||
{
|
||||
options.services.slackspawn = {
|
||||
enable = lib.mkEnableOption "slackspawn";
|
||||
mode = lib.mkOption {
|
||||
type = lib.types.enum [ "master" "slave" ];
|
||||
default = "master";
|
||||
};
|
||||
clusterPort = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.port;
|
||||
default = null;
|
||||
description = "On the master: open this port for slaves (match cluster.listen).";
|
||||
};
|
||||
configFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
};
|
||||
environmentFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = "SLACK_APP_TOKEN, SLACK_BOT_TOKEN, CLUSTER_SECRET and API keys, kept out of the Nix store.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.network.enable = true;
|
||||
systemd.network.networks."80-container-ve" = {
|
||||
matchConfig.Name = "ve-*";
|
||||
networkConfig = {
|
||||
Address = "0.0.0.0/28";
|
||||
LinkLocalAddressing = "yes";
|
||||
DHCPServer = true;
|
||||
IPMasquerade = "both";
|
||||
};
|
||||
};
|
||||
networking.firewall.trustedInterfaces = [ "ve-+" ];
|
||||
networking.firewall.allowedTCPPorts = lib.optional (cfg.clusterPort != null) cfg.clusterPort;
|
||||
|
||||
systemd.services.slackspawn = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" "systemd-machined.service" ];
|
||||
wants = [ "network-online.target" ];
|
||||
path = [ pkgs.systemd pkgs.btrfs-progs ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${self.packages.${pkgs.stdenv.hostPlatform.system}.default}/bin/slackspawn -mode ${cfg.mode} -config ${cfg.configFile}";
|
||||
EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
|
||||
StateDirectory = "slackspawn";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user