10 cfg = config.services.workout-tracker;
11 stateDir = "workout-tracker";
16 services.workout-tracker = {
17 enable = lib.mkEnableOption "workout tracking web application for personal use (or family, friends), geared towards running and other GPX-based activities";
19 package = lib.mkPackageOption pkgs "workout-tracker" { };
21 address = lib.mkOption {
23 default = "127.0.0.1";
24 description = "Web interface address.";
30 description = "Web interface port.";
33 environmentFile = lib.mkOption {
34 type = types.nullOr types.path;
36 example = "/run/keys/workout-tracker.env";
38 An environment file as defined in {manpage}`systemd.exec(5)`.
40 Secrets like `WT_JWT_ENCRYPTION_KEY` may be passed to the service without adding them
41 to the world-readable Nix store.
45 settings = lib.mkOption {
46 type = types.attrsOf types.str;
55 WT_DATABASE_DRIVER = "sqlite";
56 WT_DSN = "./database.db";
62 config = lib.mkIf cfg.enable {
63 systemd.services.workout-tracker = {
64 description = "A workout tracking web application for personal use (or family, friends), geared towards running and other GPX-based activities";
65 wantedBy = [ "multi-user.target" ];
67 WT_BIND = "${cfg.address}:${toString cfg.port}";
68 WT_DATABASE_DRIVER = "sqlite";
69 WT_DSN = "./database.db";
72 ExecStart = lib.getExe cfg.package;
74 StateDirectory = stateDir;
75 WorkingDirectory = "%S/${stateDir}";
77 EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
82 meta.maintainers = with lib.maintainers; [ bhankas ];