From 95fbfb2339e98fac2ed7cd626fab94e5dd360d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sat, 7 Feb 2026 04:25:38 +0100 Subject: [PATCH] chore: extract version from main.go in flake.nix Use builtins.match to parse version from cmd/homelab-deploy/main.go so only one location needs updating when bumping versions. Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 4 +--- flake.nix | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 4c88c4d..c0b7edb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -113,9 +113,7 @@ Follow semantic versioning: - **Minor** (0.x.0): Non-breaking changes adding features - **Major** (x.0.0): Breaking changes -Update the version in **both** locations: -1. `const version` in `cmd/homelab-deploy/main.go` -2. `version` field in `flake.nix` +Update `const version` in `cmd/homelab-deploy/main.go`. The Nix build extracts the version from there automatically. **When to bump**: If any Go code has changed, bump the version before committing. Do this automatically when asked to commit. On feature branches, only bump once per branch (check if version has already been bumped compared to master). diff --git a/flake.nix b/flake.nix index 961d380..f8542bf 100644 --- a/flake.nix +++ b/flake.nix @@ -15,11 +15,16 @@ packages = forAllSystems (system: let pkgs = pkgsFor system; + # Extract version from main.go + version = builtins.head ( + builtins.match ''.*const version = "([^"]+)".*'' + (builtins.readFile ./cmd/homelab-deploy/main.go) + ); in { homelab-deploy = pkgs.buildGoModule { pname = "homelab-deploy"; - version = "0.1.0"; + inherit version; src = ./.; vendorHash = "sha256-JXa+obN62zrrwXlplqojY7dvEunUqDdSTee6N8c5JTg="; subPackages = [ "cmd/homelab-deploy" ];