Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
test: add a NixOS VM integration test for the module
gerrydoroff88e3260b94
diff --git a/docs/NIX.md b/docs/NIX.mdindex ef6b182d2..55d44c40f 100644--- a/docs/NIX.md+++ b/docs/NIX.md@@ -22,6 +22,8 @@ managed by your NixOS configuration. This document covers both.| `apps.opengym` | Runs `opengym-api` alone (`nix run .#opengym`). || `devShells.default` | Development shell: Node.js 22, coreutils, git. || `checks.nixos-module-eval` | Evaluates the module against a smoke-test config and asserts the resulting services/users/nginx state and extra environment. |+| `checks.opengym-nixos-test` *(Linux)* | Boots a NixOS VM and exercises the HTTP contract end to end (API health, nginx vhost proxy, SPA fallback). |+| `nixosTests.opengym` | The same VM test under the conventional `nixosTests` output. || `nixosModules.opengym` | The NixOS module (`nixosModules.default` aliases it). |### What the NixOS module does@@ -82,7 +84,8 @@ nix build .#opengym-api # API → result/bin/opengym-apinix build .#opengym-mcpnix run .#opengym # run the API alone (listening on :3000)nix develop # dev shell: nodejs_22, git, coreutils-nix flake check # builds + runs the module eval check+nix flake check # eval check + (on Linux) the VM integration test+nix build .#nixosTests.opengym # run just the VM integration test````nix run .#opengym` starts only the API server. To poke at the full stack locally you need a webdiff --git a/flake.nix b/flake.nixindex 1b9aaa4ad..c3fb98185 100644--- a/flake.nix+++ b/flake.nix@@ -108,7 +108,15 @@apps.default = self.apps.${system}.opengym;- checks.nixos-module-eval = check;+ checks = {+ nixos-module-eval = check;+ } // (pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {+ # Boots a NixOS VM and exercises the full HTTP contract (API + nginx vhost + SPA).+ opengym-nixos-test = import ./nix/tests.nix {+ inherit pkgs;+ modules = [ opengymNixOSModule ];+ };+ });devShells.default = pkgs.mkShell {buildInputs = with pkgs; [@@ -135,5 +143,11 @@_module.args.opengymPkgs = self.packages.${pkgs.system} or null;};nixosModules.default = self.nixosModules.opengym;++ # Conventional NixOS test output (boots a VM; also wired into checks on Linux).+ nixosTests.opengym = import ./nix/tests.nix {+ pkgs = nixpkgs.legacyPackages.x86_64-linux;+ modules = [ self.nixosModules.opengym ];+ };};}diff --git a/nix/tests.nix b/nix/tests.nixnew file mode 100644index 000000000..8a0420117--- /dev/null+++ b/nix/tests.nix@@ -0,0 +1,51 @@+# Integration test: boots a NixOS VM with the openGym module (full stack: API + optional+# module-managed nginx vhost + build-time media) and exercises the HTTP contract end to end.+#+# Used through the flake's `checks.opengym-nixos-test` (runs on `nix flake check`) and the+# conventional `nixosTests.opengym` output.+{+ pkgs,+ modules,+}:++pkgs.testers.runNixOSTest {+ name = "opengym";++ nodes.machine =+ { pkgs, ... }:+ {+ imports = modules;++ services.opengym = {+ enable = true;+ rpId = "localhost";+ origin = "http://localhost:8080";+ media.fetchAtBuild = true; # media baked into the store — no network needed in the VM+ nginx.enable = true; # exercise the module-managed vhost path+ };++ system.stateVersion = "25.05";+ environment.systemPackages = [ pkgs.curl ];+ };++ testScript = ''+ start_all()++ machine.wait_for_unit("opengym-api.service")+ machine.wait_for_open_port(3000)++ direct = machine.succeed("curl -fsS http://127.0.0.1:3000/api/health")+ machine.log(f"[direct] {direct}")+ assert '"ok":true' in direct, f"unexpected /api/health body: {direct}"++ machine.wait_for_unit("nginx.service")+ machine.wait_for_open_port(80)++ via_nginx = machine.succeed("curl -fsS http://localhost/api/health")+ machine.log(f"[via nginx] {via_nginx}")+ assert '"ok":true' in via_nginx, f"nginx proxy returned: {via_nginx}"++ spa = machine.succeed("curl -fsS http://localhost/")+ assert 'id="root"' in spa, "SPA index.html not served by nginx root"+ '';+}\ No newline at end of file