From c12182484a5653a07d9e064e2bf9e211e537cb67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Krop=C3=A1=C4=8Dek?= Date: Thu, 14 Nov 2024 20:05:28 +0100 Subject: [PATCH] patching is da wae --- nix/migrate-version.patch | 22 ++++++++++++++++++++++ nix/sql-migrate.nix | 9 ++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 nix/migrate-version.patch diff --git a/nix/migrate-version.patch b/nix/migrate-version.patch new file mode 100644 index 0000000..799573f --- /dev/null +++ b/nix/migrate-version.patch @@ -0,0 +1,22 @@ +diff --git a/sql-migrate/config.go b/sql-migrate/config.go +index 6947a53..df394d8 100644 +--- a/sql-migrate/config.go ++++ b/sql-migrate/config.go +@@ -6,7 +6,6 @@ import ( + "flag" + "fmt" + "os" +- "runtime/debug" + + "github.com/go-gorp/gorp/v3" + "gopkg.in/yaml.v2" +@@ -112,8 +111,5 @@ func GetConnection(env *Environment) (*sql.DB, string, error) { + + // GetVersion returns the version. + func GetVersion() string { +- if buildInfo, ok := debug.ReadBuildInfo(); ok && buildInfo.Main.Version != "(devel)" { +- return buildInfo.Main.Version +- } +- return "dev" ++ return "@current_version@" + } diff --git a/nix/sql-migrate.nix b/nix/sql-migrate.nix index fb5188e..9d53dcc 100644 --- a/nix/sql-migrate.nix +++ b/nix/sql-migrate.nix @@ -2,6 +2,7 @@ , lib , buildGoModule , fetchFromGitHub +, substituteAll }: buildGoModule rec { @@ -20,7 +21,13 @@ buildGoModule rec { ldflags = [ "-s" "-w" - "-X Main.Version=v${version}" + ]; + + patches = [ + (substituteAll { + src = ./migrate-version.patch; + current_version = "v${version}"; + }) ]; doCheck = false;