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

Options/Parser: add '--long-version' that adds debug information #712

Conversation

Anton-Latukha
Copy link
Collaborator

Option for debugging and bugreporting purposes.

Current output:

Version: 0.9.1
Commit: 2dc211314eee32e02f83de16062a5c1355e11fc7
  date: Sat Sep 12 13:31:59 2020 +0300
  branch: 2020-09-12-add-GitRev-to-version

Also date and branch is to direct contributors attention to updating (or having
in mind) that.

M hnix.cabal
M src/Nix/Options/Parser.hs

Option for debugging and bugreporting purposes.

Current output:
```
Version: 0.9.1
Commit: 2dc2113
  date: Sat Sep 12 13:31:59 2020 +0300
  branch: 2020-09-12-add-GitRev-to-version
```

Also date and branch is to direct contributors attention to updating (or having
in mind) that.

M  hnix.cabal
M  src/Nix/Options/Parser.hs
@Anton-Latukha Anton-Latukha marked this pull request as draft September 12, 2020 15:29
@Anton-Latukha
Copy link
Collaborator Author

Anton-Latukha commented Sep 13, 2020

Branch information probably is excessive, it is probably should be reduced by YAGNI principle. But well, if project would diverge into several branches (which is not likely). So the branch report is YAGNI.

@Anton-Latukha
Copy link
Collaborator Author

Anton-Latukha commented Sep 13, 2020

There is a way to extract the version informaiton into into the executable using Template Haskell, that should untie HNix from Cabal machinery in this particular place.

But there seems to be no package/module to do that the nice way.

I sorta do not want to drag unbeliever core-program into HNix just for Core.Program.Metadata to retrieve 'Verison` in a somewhat more portable form, so for now it left in a more simple Cabal metadata manner but with comment that the Template Haskell is possible and in the far future preferred there.

@Anton-Latukha
Copy link
Collaborator Author

Anton-Latukha commented Sep 13, 2020

This PR seems straight-forward.

I would remove branch report from it, and include the rest into today's 0.11.0.

@Anton-Latukha Anton-Latukha marked this pull request as ready for review September 13, 2020 10:24
@Anton-Latukha
Copy link
Collaborator Author

Anton-Latukha commented Sep 13, 2020

Well, nix-building gives:

> hnix --long-version

Version: 0.10.0
Commit: UNKNOWN
  date: UNKNOWN

So the Template Haskell returns info only for the canonical cabal builds.

nix-build AFAIR strips the source code before including it into closure compilation processes, which means all SVC/Git metadata stripped from it also, so there is nowhere to get it from during the nix-build. The bummer... But there is no way to avoid this optimally easily.

But the ideal should not be the enemy of the good. 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.

The most important that canonical Cabal works.

@Anton-Latukha Anton-Latukha merged commit 83c5cea into haskell-nix:master Sep 13, 2020
@Anton-Latukha Anton-Latukha deleted the 2020-09-12-add-GitRev-to-version branch September 13, 2020 10:52
Anton-Latukha added a commit that referenced this pull request Sep 13, 2020
[Remark](#712 (comment)) deserves a comment note in the source code.
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

Successfully merging this pull request may close these issues.

1 participant