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: debugVersionOpt: comment: add nix-build note #717

Merged
merged 1 commit into from
Sep 13, 2020

Conversation

Anton-Latukha
Copy link
Collaborator

@Anton-Latukha Anton-Latukha commented Sep 13, 2020

Remark deserves a comment note in the source code.

@Anton-Latukha Anton-Latukha changed the title Options/Parser: debugVersionOpt: comment: add nix-build Options/Parser: debugVersionOpt: comment: add nix-build note Sep 13, 2020
@Anton-Latukha Anton-Latukha force-pushed the 2020-09-13-add-comment-to-CLI-long-version branch from 82aad8a to 2dccb29 Compare September 13, 2020 11:09
@Anton-Latukha Anton-Latukha merged commit 1beaf46 into master Sep 13, 2020
@Anton-Latukha Anton-Latukha deleted the 2020-09-13-add-comment-to-CLI-long-version branch September 13, 2020 11:10
@alexfmpe
Copy link
Contributor

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 $@
';

@alexfmpe
Copy link
Contributor

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

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.

2 participants