wip nixos service

This commit is contained in:
Jill 2023-03-23 23:36:54 +03:00
parent 77b809da8c
commit 286a2eb9a8
Signed by: oat
GPG Key ID: 33489AA58A955108
1 changed files with 56 additions and 0 deletions

View File

@ -47,5 +47,61 @@
shards
];
};
nixosModule = { config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.crystal-gauntlet;
in {
options.services.crystal-gauntlet = {
enable = mkEnableOption "Enables the crystal-gauntlet server";
domain = mkOption {
type = types.nullOr types.str;
default = null;
description = "Which domain to host the server under; if disabled, NGINX is not used";
};
port = mkOption {
type = types.port;
default = 8050;
};
package = mkOption {
type = types.package;
default = self.packages.${system}.default;
};
};
config = mkIf cfg.enable {
systemd.services."crystal-gauntlet" = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Restart = "on-failure";
ExecStart = "${getExe cfg.package}";
DynamicUser = "yes";
RuntimeDirectory = "crystal-gauntlet";
RuntimeDirectoryMode = "0755";
StateDirectory = "crystal-gauntlet";
StateDirectoryMode = "0700";
CacheDirectory = "crystal-gauntlet";
CacheDirectoryMode = "0750";
};
};
services.nginx = mkIf cfg.domain {
virtualHosts."${cfg.domain}" = {
enableACME = true;
forceSSL = false;
addSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${cfg.port}/";
};
extraConfig = ''
client_max_body_size 500M;
'';
};
};
};
};
});
}