OwOpointTracker/module.nix

91 lines
1.8 KiB
Nix
Raw Normal View History

2024-10-09 09:42:54 +02:00
self: {pkgs, lib, ...}:
2024-10-09 08:14:47 +02:00
with lib;
let
cfg = config.services.owOPointTracker;
format = pkgs.formats.yaml {};
2024-10-09 09:40:01 +02:00
configFile = format.generate "settings.yml" cfg.config;
2024-10-09 08:14:47 +02:00
databaseOptionType = types.submodule {
options = {
database = mkOption {
default = "_env:YESOD_SQLITE_DATABASE:OwOpointTracker.sqlite3";
type = types.str;
};
poolsize = mkOption {
default = "_env:YESOD_SQLITE_POOLSIZE:10";
type = types.str;
};
};
};
stationType = types.submodule {
options = {
station-id = mkOption {
default = "Station";
type = types.str;
};
station-name = mkOption {
types = types.str;
};
};
};
2024-10-09 09:41:25 +02:00
in
2024-10-09 08:14:47 +02:00
{
imports = [];
options.services.owOPointTracker = {
enable = mkEnableOption "OwOPointTracker";
2024-10-09 09:44:28 +02:00
configFile = {
2024-10-09 08:14:47 +02:00
static-dir = mkOption {
type = types.path;
};
host = mkOption {
type = types.str;
default = "_env:YESOD_HOST:*4";
ad-files = mkOption {
type = types.path;
};
port = mkOption {
default = "_env:YESOD_PORT:3000";
type = types.str;
};
ip-from-header = mkOption {
default = "_env:YESOD_IP_FROM_HEADER:false";
type = types.str;
};
database = {
type = databaseOptionType;
};
copyright = mkOption {
default = "copyright for this mess?";
type = types.str;
};
station = mkOption {
type = types.listOf stationType;
};
};
};
config = mkIf cfg.enable {
users.users.owopoint = {
isSystemUser = true;
group = "owopoint";
createHome = true;
home = "/var/owopoint";
};
users.groups = {
owopoint = {};
};
systemd.services.owOPointTracker = {
wantedBy = ["multi-user.target"];
after = ["network.target"];
serviceConfig = {
ExecStart = "${self.packages.${pkgs.system}.default} ${configFile}";
Restart = always;
User = "owopoint";
Group = "owopoint";
};
};
};
}