mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-11 07:15:54 +03:00
nixos/workout-tracker: init
This commit is contained in:
parent
050f4664b5
commit
466b994af9
@ -95,6 +95,8 @@ Use `services.pipewire.extraConfig` or `services.pipewire.configPackages` for Pi
|
||||
|
||||
- [hebbot](https://github.com/haecker-felix/hebbot), a Matrix bot to generate "This Week in X" like blog posts. Available as [services.hebbot](#opt-services.hebbot.enable).
|
||||
|
||||
- [Workout-tracker](https://github.com/jovandeginste/workout-tracker), a workout tracking web application for personal use.
|
||||
|
||||
- [Python Matter Server](https://github.com/home-assistant-libs/python-matter-server), a
|
||||
Matter Controller Server exposing websocket connections for use with other services, notably Home Assistant.
|
||||
Available as [services.matter-server](#opt-services.matter-server.enable)
|
||||
|
@ -796,6 +796,7 @@
|
||||
./services/misc/tzupdate.nix
|
||||
./services/misc/uhub.nix
|
||||
./services/misc/weechat.nix
|
||||
./services/misc/workout-tracker.nix
|
||||
./services/misc/xmr-stak.nix
|
||||
./services/misc/xmrig.nix
|
||||
./services/misc/zoneminder.nix
|
||||
|
83
nixos/modules/services/misc/workout-tracker.nix
Normal file
83
nixos/modules/services/misc/workout-tracker.nix
Normal file
@ -0,0 +1,83 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) types;
|
||||
cfg = config.services.workout-tracker;
|
||||
stateDir = "workout-tracker";
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
services.workout-tracker = {
|
||||
enable = lib.mkEnableOption "workout tracking web application for personal use (or family, friends), geared towards running and other GPX-based activities";
|
||||
|
||||
package = lib.mkPackageOption pkgs "workout-tracker" { };
|
||||
|
||||
address = lib.mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1";
|
||||
description = "Web interface address.";
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = types.port;
|
||||
default = 8080;
|
||||
description = "Web interface port.";
|
||||
};
|
||||
|
||||
environmentFile = lib.mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
example = "/run/keys/workout-tracker.env";
|
||||
description = ''
|
||||
An environment file as defined in {manpage}`systemd.exec(5)`.
|
||||
|
||||
Secrets like `WT_JWT_ENCRYPTION_KEY` may be passed to the service without adding them
|
||||
to the world-readable Nix store.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
|
||||
default = { };
|
||||
description = ''
|
||||
Extra config options.
|
||||
'';
|
||||
example = {
|
||||
WT_LOGGING = "true";
|
||||
WT_DEBUG = "false";
|
||||
WT_DATABASE_DRIVER = "sqlite";
|
||||
WT_DSN = "./database.db";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.workout-tracker = {
|
||||
description = "A workout tracking web application for personal use (or family, friends), geared towards running and other GPX-based activities";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = {
|
||||
WT_BIND = "${cfg.address}:${toString cfg.port}";
|
||||
WT_DATABASE_DRIVER = "sqlite";
|
||||
WT_DSN = "./database.db";
|
||||
} // cfg.settings;
|
||||
serviceConfig = {
|
||||
ExecStart = lib.getExe cfg.package;
|
||||
DynamicUser = true;
|
||||
StateDirectory = stateDir;
|
||||
WorkingDirectory = "%S/${stateDir}";
|
||||
Restart = "always";
|
||||
EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ bhankas ];
|
||||
}
|
@ -991,6 +991,7 @@ in {
|
||||
wireguard = handleTest ./wireguard {};
|
||||
without-nix = handleTest ./without-nix.nix {};
|
||||
wmderland = handleTest ./wmderland.nix {};
|
||||
workout-tracker = handleTest ./workout-tracker.nix {};
|
||||
wpa_supplicant = handleTest ./wpa_supplicant.nix {};
|
||||
wordpress = handleTest ./wordpress.nix {};
|
||||
wrappers = handleTest ./wrappers.nix {};
|
||||
|
29
nixos/tests/workout-tracker.nix
Normal file
29
nixos/tests/workout-tracker.nix
Normal file
@ -0,0 +1,29 @@
|
||||
import ./make-test-python.nix (
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "workout-tracker";
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ bhankas ];
|
||||
|
||||
nodes.machine =
|
||||
{ config, ... }:
|
||||
{
|
||||
virtualisation.memorySize = 2048;
|
||||
|
||||
services.workout-tracker.enable = true;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
machine.wait_for_unit("workout-tracker.service")
|
||||
# wait for workout-tracker to fully come up
|
||||
|
||||
with subtest("workout-tracker service starts"):
|
||||
machine.wait_until_succeeds(
|
||||
"curl -sSfL http://localhost:8080/ > /dev/null",
|
||||
timeout=30
|
||||
)
|
||||
'';
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue
Block a user