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
nix: move the flake under contrib/nix
gerrydoroe7e210edb0ad
diff --git a/nix/api.nix b/contrib/nix/api.nixsimilarity index 98%rename from nix/api.nixrename to contrib/nix/api.nixindex 0de411efe..ac2015bf4 100644--- a/nix/api.nix+++ b/contrib/nix/api.nix@@ -11,7 +11,7 @@ buildNpmPackage rec {pname = "opengym-api";inherit version;- src = ./../api;+ src = ./../../api;nodejs = nodejs_22;diff --git a/nix/default.nix b/contrib/nix/default.nixsimilarity index 100%rename from nix/default.nixrename to contrib/nix/default.nixdiff --git a/flake.lock b/contrib/nix/flake.locksimilarity index 100%rename from flake.lockrename to contrib/nix/flake.lockdiff --git a/flake.nix b/contrib/nix/flake.nixsimilarity index 77%rename from flake.nixrename to contrib/nix/flake.nixindex fa973b857..922df8b01 100644--- a/flake.nix+++ b/contrib/nix/flake.nix@@ -18,7 +18,7 @@letpkgs = nixpkgs.legacyPackages.${system};- opengymPackages = import ./nix/default.nix { inherit pkgs; };+ opengymPackages = import ./default.nix { inherit pkgs; };opengymNixOSModule = self.nixosModules.opengym;@@ -32,7 +32,9 @@rpId = "localhost";origin = "http://localhost:8080";apiPort = 3000;- environment = { MY_FLAG = "1"; };+ environment = {+ MY_FLAG = "1";+ };media.fetchAtBuild = true;};system.stateVersion = "25.05";@@ -68,19 +70,35 @@echo "services.opengym.origin = ${cfg.origin}"# Verify systemd service exists- echo "systemd.services.opengym-api exists = ${if testConfig.config.systemd.services ? opengym-api then "true" else "false"}"+ echo "systemd.services.opengym-api exists = ${+ if testConfig.config.systemd.services ? opengym-api then "true" else "false"+ }"# Verify extra environment is applied to the API unit- echo "opengym-api env MY_FLAG = ${if testConfig.config.systemd.services.opengym-api.environment ? MY_FLAG then testConfig.config.systemd.services.opengym-api.environment.MY_FLAG else "missing"}"+ echo "opengym-api env MY_FLAG = ${+ if testConfig.config.systemd.services.opengym-api.environment ? MY_FLAG then+ testConfig.config.systemd.services.opengym-api.environment.MY_FLAG+ else+ "missing"+ }"# Verify nginx is disabled by default (system uses Caddy)echo "services.nginx.enable (default) = ${if nginxEnabled then "true" else "false"}"# Verify the optional managed nginx vhost gets configured- echo "services.nginx.enable (nginx.enable) = ${if nginxTestConfig.config.services.nginx.enable then "true" else "false"}"- echo "nginx vhost for 'localhost' = ${if nginxTestConfig.config.services.nginx.virtualHosts ? localhost then "true" else "false"}"- echo "nginx /api proxyPass = ${nginxTestConfig.config.services.nginx.virtualHosts."localhost".locations."/api/".proxyPass or "missing"}"- echo "nginx /img alias = ${nginxTestConfig.config.services.nginx.virtualHosts."localhost".locations."/img/".alias or "missing"}"+ echo "services.nginx.enable (nginx.enable) = ${+ if nginxTestConfig.config.services.nginx.enable then "true" else "false"+ }"+ echo "nginx vhost for 'localhost' = ${+ if nginxTestConfig.config.services.nginx.virtualHosts ? localhost then "true" else "false"+ }"+ echo "nginx /api proxyPass = ${+ nginxTestConfig.config.services.nginx.virtualHosts."localhost".locations."/api/".proxyPass+ or "missing"+ }"+ echo "nginx /img alias = ${+ nginxTestConfig.config.services.nginx.virtualHosts."localhost".locations."/img/".alias or "missing"+ }"# Verify frontend/media store paths are exposed for a web serverecho "services.opengym.web.root = ${cfg.web.root}"@@ -88,7 +106,9 @@echo "services.opengym.media.gifRoot = ${cfg.media.gifRoot}"# Verify user exists- echo "users.users.opengym exists = ${if testConfig.config.users.users ? opengym then "true" else "false"}"+ echo "users.users.opengym exists = ${+ if testConfig.config.users.users ? opengym then "true" else "false"+ }"# All checks passedtouch $out@@ -164,9 +184,10 @@checks = {nixos-module-eval = check;- } // (pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {+ }+ // (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 {+ opengym-nixos-test = import ./tests.nix {inherit pkgs;modules = [ opengymNixOSModule ];};@@ -188,18 +209,18 @@)// {# Wraps the module so NixOS configurations using it get openGym packages built from this- # flake's LOCKED nixpkgs input. Importing nix/opengym.nix directly falls back to the- # importing system's nixpkgs.+ # flake's LOCKED nixpkgs input. Importing contrib/nix/opengym.nix directly falls back to+ # the importing system's nixpkgs.nixosModules.opengym ={ pkgs, ... }:{- imports = [ ./nix/opengym.nix ];+ imports = [ ./opengym.nix ];_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 {+ nixosTests.opengym = import ./tests.nix {pkgs = nixpkgs.legacyPackages.x86_64-linux;modules = [ self.nixosModules.opengym ];};diff --git a/nix/frontend.nix b/contrib/nix/frontend.nixsimilarity index 98%rename from nix/frontend.nixrename to contrib/nix/frontend.nixindex 9e70761cf..033a4fb8a 100644--- a/nix/frontend.nix+++ b/contrib/nix/frontend.nix@@ -12,7 +12,7 @@ buildNpmPackage rec {# The frontend imports api/coach/core/* (../../../api/coach/core/…), so the build# needs the repo root — same layout the Dockerfile uses (see web/Dockerfile).- src = ./..;+ src = ./../..;npmRoot = "frontend";nodejs = nodejs_22;diff --git a/nix/mcp.nix b/contrib/nix/mcp.nixsimilarity index 96%rename from nix/mcp.nixrename to contrib/nix/mcp.nixindex b1b8787f2..5b7e574ea 100644--- a/nix/mcp.nix+++ b/contrib/nix/mcp.nix@@ -11,10 +11,10 @@ buildNpmPackage rec {pname = "opengym-mcp";inherit version;- src = ./../mcp;+ src = ./../../mcp;# The MCP server reads shared domain helpers from the sibling frontend/src/lib; include them.- frontendSrc = ./../frontend;+ frontendSrc = ./../../frontend;nodejs = nodejs_22;diff --git a/nix/media-script.nix b/contrib/nix/media-script.nixsimilarity index 100%rename from nix/media-script.nixrename to contrib/nix/media-script.nixdiff --git a/nix/media.nix b/contrib/nix/media.nixsimilarity index 100%rename from nix/media.nixrename to contrib/nix/media.nixdiff --git a/nix/opengym.nix b/contrib/nix/opengym.nixsimilarity index 100%rename from nix/opengym.nixrename to contrib/nix/opengym.nixdiff --git a/nix/tests.nix b/contrib/nix/tests.nixsimilarity index 100%rename from nix/tests.nixrename to contrib/nix/tests.nixdiff --git a/nix/version.nix b/contrib/nix/version.nixsimilarity index 100%rename from nix/version.nixrename to contrib/nix/version.nixdiff --git a/docs/NIX.md b/docs/NIX.mdindex 0e680742c..0e447455d 100644--- a/docs/NIX.md+++ b/docs/NIX.md@@ -9,7 +9,8 @@ managed by your NixOS configuration. This document covers both.### What the flake provides-`flake.nix` (inputs: `nixpkgs` on `nixos-unstable`, `flake-utils`) exposes, per supported system:+`contrib/nix/flake.nix` (inputs: `nixpkgs` on `nixos-unstable`, `flake-utils`) exposes, per+supported system:| Output | What it is || --- | --- |@@ -63,24 +64,32 @@ browser ── HTTPS ──▶ your web server (Caddy / nginx / …) eve## 2. Repository layout```text-flake.nix Flake entry point — packages, apps, devShell, module alias-nix/- opengym.nix The NixOS module (options + systemd/nginx wiring)- frontend.nix buildNpmPackage → $out/share/opengym- api.nix buildNpmPackage → bin/opengym-api- mcp.nix buildNpmPackage → bin/opengym-mcp- media.nix fetchFromGitHub pin of the exercise dataset (build-time)- media-script.nix runtime media-fetch shell script- version.nix version = "1.2.14" + pinned dataset commit (single source of truth)- default.nix package-set aggregator (used by both the flake and the module)+contrib/nix/+ flake.nix Flake entry point — packages, apps, devShell, module alias+ flake.lock Locked inputs+ opengym.nix The NixOS module (options + systemd/nginx wiring)+ frontend.nix buildNpmPackage → $out/share/opengym+ api.nix buildNpmPackage → bin/opengym-api+ mcp.nix buildNpmPackage → bin/opengym-mcp+ media.nix fetchFromGitHub pin of the exercise dataset (build-time)+ media-script.nix runtime media-fetch shell script+ version.nix version = "1.2.14" + pinned dataset commit (single source of truth)+ default.nix package-set aggregator (used by both the flake and the module)```+Everything Nix lives under `contrib/nix/` so the flake stays out of the way of the project's own+build (Docker, CI, the Node packages). The flake reads its sources — `api/`, `frontend/`, `mcp/`+— from the repository root two levels up, so it must be evaluated *from a checkout of the whole+repo*, never from a sparse copy of `contrib/nix` alone.+## 3. Building and using the packagesRequirements: Nix with flakes enabled (`nix.conf`: `experimental-features = nix-command flakes`).```bash-# from a checkout of the repo+# the flake lives in contrib/nix — start there (from the repo root: nix build ./contrib/nix#… )+cd contrib/nix+nix build .#opengym-frontend # static site → result/share/opengymnix build .#opengym-api # API → result/bin/opengym-apinix build .#opengym-mcp@@ -221,7 +230,8 @@ word-for-word.{inputs = {nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";- opengym.url = "git+https://gitlab.com/DuarteSantos8/opengym";+ # the flake lives in a subdirectory — ?dir= points at it+ opengym.url = "github:DuarteSantos8/openGym?dir=contrib/nix";};outputs = { self, nixpkgs, opengym, ... }: {@@ -236,22 +246,26 @@ word-for-word.}```+On the GitLab mirror the same input is+`"git+https://gitlab.com/DuarteSantos8/opengym?dir=contrib/nix"`.+Then `sudo nixos-rebuild switch --flake .#myhost`.Not using flakes in your NixOS config? You can also `imports` the module file directly from acheckout of the repo:```nix-{ imports = [ "/path/to/opengym/nix/opengym.nix" ]; }+{ imports = [ "/path/to/opengym/contrib/nix/opengym.nix" ]; }```#### Package provenanceWhen you load the module *through the flake* (`opengym.nixosModules.default`), the default`services.opengym.package` set is the one built by this flake — from the flake's **locked**-`nixpkgs` input. Importing `nix/opengym.nix` directly instead falls back to building the packages-from *your system's* nixpkgs, which may differ slightly. If you ever need a specific set, override-`services.opengym.package` explicitly (e.g. `opengym.packages.x86_64-linux` from your flake inputs).+`nixpkgs` input. Importing `contrib/nix/opengym.nix` directly instead falls back to building the+packages from *your system's* nixpkgs, which may differ slightly. If you ever need a specific set,+override `services.opengym.package` explicitly (e.g. `opengym.packages.x86_64-linux` from your flake+inputs).### Minimal enable (works on `localhost`)diff --git a/docs/README.md b/docs/README.mdindex db092dedc..09f0e65d3 100644--- a/docs/README.md+++ b/docs/README.md@@ -24,6 +24,7 @@ to install.| [Kubernetes](SELF_HOSTING_KUBERNETES.md) | You run a cluster instead of Docker Compose || [AI coach](AI_COACH.md) | You're deciding whether to turn the coach on, and with which provider || [MCP server](../mcp/README.md) | You want Claude Desktop, Cursor or another AI client to read your training history |+| [NixOS](NIX.md) | You run NixOS and want openGym native — flake packages and a NixOS module, no Docker || [Security](../SECURITY.md) | You host it for other people, or want to report a vulnerability |All settings live in `.env`; [`.env.example`](../.env.example) explains each one, and the