wip nixos service
This commit is contained in:
parent
77b809da8c
commit
286a2eb9a8
56
flake.nix
56
flake.nix
|
@ -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;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue