From e022009a8c3294bef5af4a622a8a8f33d3c28c09 Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Thu, 21 Aug 2025 23:10:46 -0400 Subject: [PATCH] nix: grab version from build_config.go --- flake.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 3ca5c0f..d18501f 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,22 @@ self, nixpkgs, }: let - version = "3.2.0"; + version = let + buildConfig = builtins.readFile ./build_config.go; + lines = nixpkgs.lib.strings.splitString "\n" buildConfig; + versionExpr = "^const VERSION = \"([^\"]+)\"$"; + + findVersion = lines: + if builtins.length lines == 0 + then builtins.error "VERSION not found in build_config.go" + else let + match = builtins.match versionExpr (nixpkgs.lib.head lines); + in + if match == null + then findVersion (nixpkgs.lib.tail lines) + else builtins.elemAt match 0; + in + findVersion lines; supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];