Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake.nix: we should report a more accurate version string in --version #1700

Closed
colemickens opened this issue Feb 22, 2022 · 3 comments
Closed
Labels
A-packaging Area: Packaging and bundling C-bug Category: This is a bug

Comments

@colemickens
Copy link

Hello.

I'm running hx from the flake and want to be a good bug reported and include my version string. However, I know right now that the tip-flake-built hx doesn't report the correct version.

Depending on how the app is written, this can be easy (patch a constant) or hard (patch a constant and then find out that clap is ignoring the constant and reaching in the cargo metadata anyway).

@colemickens colemickens added the C-bug Category: This is a bug label Feb 22, 2022
@archseer
Copy link
Member

It reads the git sha, then falls back to only using the package version here:

let git_hash = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.ok()
.filter(|output| output.status.success())
.and_then(|x| String::from_utf8(x.stdout).ok());
let version: Cow<_> = match git_hash {
Some(git_hash) => format!("{} ({})", env!("CARGO_PKG_VERSION"), &git_hash[..8]).into(),
None => env!("CARGO_PKG_VERSION").into(),
};

But that will work incorrectly if building outside of the helix repository but inside a package workspace (e.g. nixpkgs or alpine's git repository) so we need to include https://github.com/tree-sitter/tree-sitter/blob/af00782dfdad02f766a76058e8631cb4edf5d894/cli/build.rs#L36-L81

We could modify build.rs so it first looks for a HELIX_GIT_HASH then tries to parse git rev-head? Then we can inject that variable during a Nix build.

@kirawi kirawi added the A-packaging Area: Packaging and bundling label Feb 24, 2022
@the-mikedavis
Copy link
Member

the-mikedavis commented Apr 17, 2022

Now with the 22.03 release:

$ nix run nixpkgs#helix -- -V
helix 22.03 (d4e45fd4)
$ nix run github:helix-editor/helix -- -V
helix 22.05-dev

🎉

(see #1875)

@the-mikedavis
Copy link
Member

the-mikedavis commented Apr 17, 2022

We can't include the git sha in the flake output because of how Nix builds. It's either in a bare directory or not in a git directory at all (I'm not sure which), so git rev-parse HEAD fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-packaging Area: Packaging and bundling C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

4 participants