Skip to content

Commit

Permalink
Fix flake rev issue (#2310)
Browse files Browse the repository at this point in the history
## 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
```
  • Loading branch information
Lagoja authored Sep 29, 2024
1 parent 37c36a1 commit fcf3a42
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 ? revCount)
then "${x}-${self.shortRev}"
else "${x}-${self.dirtyShortRev}")
];
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 "";
Expand All @@ -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
Expand Down

0 comments on commit fcf3a42

Please sign in to comment.