colima: embed version and git revision

These are shown on `colima version`

See also https://github.com/abiosoft/colima/issues/301
This commit is contained in:
Atemu 2022-05-21 19:41:06 +02:00
parent c777cdf5c5
commit 6a065534bb

View File

@ -14,13 +14,25 @@ buildGoModule rec {
owner = "abiosoft";
repo = pname;
rev = "v${version}";
sha256 = "sha256-g7q2DmtyArtW7Ii2XF5umXQ0+BlCSa1Q7VNNuIuX65k=";
sha256 = "sha256-KYW3gxf21aWnuRHkysOjArzMSNH3m3XDoi6Sic3N+Po=";
# We need the git revision
leaveDotGit = true;
postFetch = ''
git -C $out rev-parse HEAD > $out/.git-revision
rm -rf $out/.git
'';
};
nativeBuildInputs = [ installShellFiles makeWrapper ];
vendorSha256 = "sha256-Z4+qwoX04VnLsUIYRfOowFLgcaA9w8oGRl77jzFigIc=";
preConfigure = ''
ldflags="-X github.com/abiosoft/colima/config.appVersion=${version}
-X github.com/abiosoft/colima/config.revision=$(cat .git-revision)"
'';
postInstall = ''
wrapProgram $out/bin/colima \
--prefix PATH : ${lib.makeBinPath [ lima ]}