flake: { config
, lib
, pkgs
, ...
}:
let
inherit (lib) mkIf getBin types mkEnableOption mkOption;
inherit (flake.packages.${pkgs.stdenv.hostPlatform.system}) staxman;
cfg = config.services.staxman;
in
{
options.services.staxman = {
enable = mkEnableOption "staxman";
stackDir = mkOption {
type = types.path;
defaultText = "/stacks";
example = "/stacks";
description = ''
Directory containing Arion stacks
'';
};
bindAddress = mkOption
type = types.str;
default = "127.0.0.1:3000";
Bind address
config = mkIf cfg.enable {
systemd.services.staxman = {
description = "Scatting system management";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
environment.STAX_ARION_BIN = "${pkgs.arion}/bin/arion";
environment.STAX_DIR = cfg.stackDir;
environment.STAX_BIND = cfg.bindAddress;
serviceConfig = {
User = "root";
Group = "root";
Restart = "always";
ExecStart = "${getBin staxman}/bin/staxman";
}