mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Derive the version from the Cargo/pubspec manifests
The version string was duplicated across six places. Collapse it to two ecosystem sources of truth and derive the rest: - backend/src/web_server.rs: omit the OpenAPI info.version so utoipa fills it from CARGO_PKG_VERSION (backend/Cargo.toml); add a test pinning this. - nix/package.nix: read the version from backend/Cargo.toml via fromTOML. - nix/frontend.nix: read the version from frontend/pubspec.yaml by splitting into lines (a whole-file regex triggers catastrophic backtracking in Nix's regex engine). - frontend/lib/about/about.dart: read the version at runtime via package_info_plus instead of a hardcoded constant. Also drop frontend/pubspec.lock.json: it is unreferenced (Nix's autoPubspecLock generates its own JSON from pubspec.lock) and was going stale. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
dd089a9cbc
commit
4a1fe60ec3
+19
-10
@@ -1,12 +1,21 @@
|
||||
{flutter}:
|
||||
flutter.buildFlutterApplication {
|
||||
pname = "oott-frontend";
|
||||
version = "0.1.0";
|
||||
src = ./../frontend;
|
||||
{flutter}: let
|
||||
# Single source of truth: extract the version from frontend/pubspec.yaml.
|
||||
# Nix has no YAML parser, so split into lines and read the `version:` line.
|
||||
# (Matching the whole file with a single regex is avoided on purpose: nested
|
||||
# quantifiers over the full text trigger catastrophic backtracking in Nix's
|
||||
# regex engine.)
|
||||
lines = builtins.filter builtins.isString (builtins.split "\n" (builtins.readFile ./../frontend/pubspec.yaml));
|
||||
versionLine = builtins.head (builtins.filter (line: builtins.match "version:.*" line != null) lines);
|
||||
version = builtins.head (builtins.match "version: *([^ ]+) *" versionLine);
|
||||
in
|
||||
flutter.buildFlutterApplication {
|
||||
pname = "oott-frontend";
|
||||
inherit version;
|
||||
src = ./../frontend;
|
||||
|
||||
# Fetches pub dependencies from the committed pubspec.lock (all hosted, no git deps).
|
||||
autoPubspecLock = ./../frontend/pubspec.lock;
|
||||
# Fetches pub dependencies from the committed pubspec.lock (all hosted, no git deps).
|
||||
autoPubspecLock = ./../frontend/pubspec.lock;
|
||||
|
||||
# Build the web bundle (the backend serves these assets).
|
||||
targetFlutterPlatform = "web";
|
||||
}
|
||||
# Build the web bundle (the backend serves these assets).
|
||||
targetFlutterPlatform = "web";
|
||||
}
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@
|
||||
in
|
||||
pkgs.rustPlatform.buildRustPackage rec {
|
||||
pname = "oott";
|
||||
version = "0.1.0";
|
||||
# Single source of truth: read the version straight from backend/Cargo.toml.
|
||||
version = (builtins.fromTOML (builtins.readFile ./../backend/Cargo.toml)).package.version;
|
||||
src = ./../backend;
|
||||
cargoLock = {
|
||||
lockFile = ./../backend/Cargo.lock;
|
||||
|
||||
Reference in New Issue
Block a user