From 3f9408332269fe523d278f614425b29d8fe4a99a Mon Sep 17 00:00:00 2001 From: John Lago <750845+Lagoja@users.noreply.github.com> Date: Fri, 27 Sep 2024 18:26:21 -0700 Subject: [PATCH 1/3] fix revision issue --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 2ed7a4d5f2f..491fd2f26e9 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Instant, easy, predictable shells and containers"; + description = "Instant, easy, predictable dev environments"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -16,9 +16,9 @@ # Add the commit to the version string, in case someone builds from main getVersion = pkgs.lib.trivial.pipe self [ (x: "${lastTag}") - (x: if (self ? revCount) + (x: if (self ? shortRev) then "${x}-${self.shortRev}" - else "${x}-${self.dirtyShortRev}") + else "${x}-${if self ? dirtyShortRev then self.dirtyShortRev else "dirty"}") ]; # Run `devbox run update-flake` to update the vendorHash From c938b98b46226ad775d898b2e69257220cddb52f Mon Sep 17 00:00:00 2001 From: John Lago <750845+Lagoja@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:50:10 -0700 Subject: [PATCH 2/3] use or syntax --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 491fd2f26e9..966cd625c28 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ (x: "${lastTag}") (x: if (self ? shortRev) then "${x}-${self.shortRev}" - else "${x}-${if self ? dirtyShortRev then self.dirtyShortRev else "dirty"}") + else "${x}-${self.dirtyShortRev or "dirty"}") ]; # Run `devbox run update-flake` to update the vendorHash From 70e00573685923dd8f8e3bc0505cb32f13273062 Mon Sep 17 00:00:00 2001 From: John Lago <750845+Lagoja@users.noreply.github.com> Date: Sun, 29 Sep 2024 10:45:21 -0700 Subject: [PATCH 3/3] simplify, remove rec, add build.Commit --- flake.nix | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index 966cd625c28..7eac76384f1 100644 --- a/flake.nix +++ b/flake.nix @@ -13,15 +13,14 @@ lastTag = "0.13.2"; - # Add the commit to the version string, in case someone builds from main - getVersion = pkgs.lib.trivial.pipe self [ - (x: "${lastTag}") - (x: if (self ? shortRev) - then "${x}-${self.shortRev}" - else "${x}-${self.dirtyShortRev or "dirty"}") - ]; + revision = if (self ? shortRev) + then "${self.shortRev}" + else "${self.dirtyShortRev or "dirty"}"; - # Run `devbox run update-flake` to update the vendorHash + # Add the commit to the version string for flake builds + version = "${lastTag}-${revision}"; + + # Run `devbox run update-flake` to update the vendor-hash vendorHash = if builtins.pathExists ./vendor-hash then builtins.readFile ./vendor-hash else ""; @@ -31,18 +30,17 @@ in { inherit self; - packages.default = buildGoModule rec { + packages.default = buildGoModule { pname = "devbox"; - version = getVersion; + inherit version vendorHash; src = ./.; - inherit vendorHash; - ldflags = [ "-s" "-w" "-X go.jetpack.io/devbox/internal/build.Version=${version}" + "-X go.jetpack.io/devbox/internal/build.Commit=${revision}" ]; # Disable tests if they require network access or are integration tests