Skip to content

Commit fcf3a42

Browse files
authored
Fix flake rev issue (#2310)
## Summary Nix flake fails to build with: ```nix error: attribute 'dirtyShortRev' missing at /nix/store/m5mqwkz0ss2cav2c9663mx8vwsmvcas3-source/flake.nix:21:28: 20| then "${x}-${self.shortRev}" 21| else "${x}-${self.dirtyShortRev}") | ^ 22| ]; ``` This fixes the issue ## How was it tested? ``` nix build github:jetify-com/devbox/jl/fix-flake-rev ```
1 parent 37c36a1 commit fcf3a42

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

flake.nix

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
description = "Instant, easy, predictable shells and containers";
2+
description = "Instant, easy, predictable dev environments";
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -13,15 +13,14 @@
1313

1414
lastTag = "0.13.2";
1515

16-
# Add the commit to the version string, in case someone builds from main
17-
getVersion = pkgs.lib.trivial.pipe self [
18-
(x: "${lastTag}")
19-
(x: if (self ? revCount)
20-
then "${x}-${self.shortRev}"
21-
else "${x}-${self.dirtyShortRev}")
22-
];
16+
revision = if (self ? shortRev)
17+
then "${self.shortRev}"
18+
else "${self.dirtyShortRev or "dirty"}";
2319

24-
# Run `devbox run update-flake` to update the vendorHash
20+
# Add the commit to the version string for flake builds
21+
version = "${lastTag}-${revision}";
22+
23+
# Run `devbox run update-flake` to update the vendor-hash
2524
vendorHash = if builtins.pathExists ./vendor-hash
2625
then builtins.readFile ./vendor-hash
2726
else "";
@@ -31,18 +30,17 @@
3130
in
3231
{
3332
inherit self;
34-
packages.default = buildGoModule rec {
33+
packages.default = buildGoModule {
3534
pname = "devbox";
36-
version = getVersion;
35+
inherit version vendorHash;
3736

3837
src = ./.;
3938

40-
inherit vendorHash;
41-
4239
ldflags = [
4340
"-s"
4441
"-w"
4542
"-X go.jetpack.io/devbox/internal/build.Version=${version}"
43+
"-X go.jetpack.io/devbox/internal/build.Commit=${revision}"
4644
];
4745

4846
# Disable tests if they require network access or are integration tests

0 commit comments

Comments
 (0)