expose *some* of the options as nixos config

This commit is contained in:
Vivian Lim 2022-10-03 22:58:34 -07:00
parent 080e711da9
commit 20851c17bd
1 changed files with 38 additions and 5 deletions

View File

@ -25,6 +25,38 @@ in
'';
};
templateDir = mkOption {
type = types.path;
default = "${cfg.package}/var/lib/bespoke/templates";
description = ''
Where to load Tera templates from.
'';
};
listenAddr = mkOption {
type = types.str;
default = "127.0.0.1";
description = ''
HTTP listen address.
'';
};
listenPort = mkOption {
type = types.int;
default = 3000;
description = ''
HTTP listen port.
'';
};
rootUrl = mkOption {
type = types.str;
default = "http://localhost:3000";
description = ''
Public root URL of bespoke server.
'';
};
package = mkOption {
type = types.package;
default = flake.defaultPackage.x86_64-linux;
@ -53,14 +85,15 @@ in
User = "bespoke";
Group = "bespoke";
Restart = "on-failure";
ExecStart = "${cfg.package}/bin/bespoke";
ExecStart = "${cfg.package}/bin/bespoke -c ${cfg.configFile}";
WorkingDirectory = "${cfg.dataDir}";
};
preStart = ''
cp -rf "${cfg.package}/var/lib/bespoke/templates" "${cfg.dataDir}"
cp -f "${cfg.configFile}" "${cfg.dataDir}/bespoke.toml"
'';
environment = {
BESPOKE_TEMPLATE_DIR = cfg.templateDir;
BESPOKE_LISTEN_ADDR = "${cfg.listenAddr}:${toString cfg.listenPort}";
BESPOKE_REDIRECT_URL = "${cfg.rootUrl}/auth/authorized";
};
};
systemd.tmpfiles.rules = [