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

Please, make --version, --long-version work for nix-build as well as for cabal #718

Open
Anton-Latukha opened this issue Sep 13, 2020 · 2 comments

Comments

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Sep 13, 2020

#717 (comment)

cabal works.

nix-building gives:

> hnix --long-version

Version: 0.10.0
Commit: UNKNOWN
  date: UNKNOWN

Thank you, @alexfmpe, for #717 (comment) info:


Ran into this exact issue on a --version for a CLI.
One can workaround by wrapping the executable and passing git data as environment variables:

root = ./.;

exe = nixpkgs.writeScript "my-package-exe" ''
  #!/usr/bin/env bash
  set -euo pipefail
  export REV=$(git -C ${root} rev-parse HEAD)
  export BRANCH=$(git -C ${root} rev-parse --abbrev-ref HEAD)
  ${nixpkgs.haskell.lib.justStaticExecutables pkgs.my-package}/bin/my-package $@
';

Downside is that it breaks --version for nix-shell cabal, though maybe more wrapping could fix that.


Lets track question here.

@Anton-Latukha
Copy link
Collaborator Author

I think that it works for Cabal is the most important, as I already covered:

If people use nix-build, we can just ask them to give us the cabal from nix-shell, which is a sort of close approximation, and if fields are empty, well - they are just additional maybe helpful info that happened to be empty. We just can request nix-shell cabal build info, which roughly approximate the case. We also may request people to try to provide commit hash manually, and UNKNOWN sort-of encourages it, if they can do it.

Haskell Language Server for Nix environments in the foreseen future would use only nix-shell cabal.

If we would develop the nix-build addition, the cabal should work also at the same time.

And it would mean that we would need to include in our Nix conf, as well Nixpkgs would need this also.

@Anton-Latukha
Copy link
Collaborator Author

Version & compile time info can be gathered with Template Haskell code - it would allow that to work under any compile tooling/env conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant