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

hcp: init at 0.8.0 #370162

Merged
merged 2 commits into from
Jan 22, 2025
Merged

hcp: init at 0.8.0 #370162

merged 2 commits into from
Jan 22, 2025

Conversation

dbreyfogle
Copy link
Contributor

Adding HCP CLI, an official project from HashiCorp for interacting with HashiCorp Cloud Platform (HCP).

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` label Jan 2, 2025
@NixOSInfra NixOSInfra added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jan 2, 2025
Copy link
Contributor

@zimward zimward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me.

preCheck = ''
export HOME=$TMPDIR
'';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to add a versionCheckHook for basic binary testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the version check but I'm getting the below error. hcp version outputs hcp v0.8.0 go1.23.4 amd64. Is the "v" prefix the issue? Tried adding glibc to nativeInstallCheckInputs but that did not work.

nativeInstallCheckInputs = [
  versionCheckHook
];
doInstallCheck = true;
versionCheckProgramArg = [ "version" ];
error: builder for '/nix/store/mkvvqzqmcn9xspbl4g5q1absgwnc0ikl-hcp-0.8.0.drv' failed with exit code 2;
       last 25 log lines:
       > ok   github.com/hashicorp/hcp/internal/pkg/auth      0.002s [no tests to run]
       > ok    github.com/hashicorp/hcp/internal/pkg/cmd       0.005s
       > ok      github.com/hashicorp/hcp/internal/pkg/flagvalue 0.002s
       > ok      github.com/hashicorp/hcp/internal/pkg/format    0.002s
       > ok      github.com/hashicorp/hcp/internal/pkg/heredoc   0.003s
       > ok      github.com/hashicorp/hcp/internal/pkg/iostreams 0.001s
       > ok      github.com/hashicorp/hcp/internal/pkg/profile   0.004s
       > ok      github.com/hashicorp/hcp/internal/pkg/table     0.002s
       > ok      github.com/hashicorp/hcp/internal/pkg/testing/promptio  0.001s [no tests to run]
       > ok    github.com/hashicorp/hcp/internal/pkg/versioncheck      0.004s
       > ok      github.com/hashicorp/hcp/internal/pkg/waypoint/agent    0.005s
       > Running phase: installPhase
       > Running phase: fixupPhase
       > shrinking RPATHs of ELF executables and libraries in /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0
       > shrinking /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0/bin/hcp
       > shrinking /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0/bin/gendocs
       > shrinking /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0/bin/mvdocs
       > checking for references to /build/ in /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0...
       > patching script interpreter paths in /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0
       > stripping (with command strip and flags -S -p) in  /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0/bin
       > Running phase: installCheckPhase
       > Executing versionCheckPhase
       > Did not find version 0.8.0 in the output of the command /nix/store/bfsl51gs7ml2fkry757n19hxgi3d2rky-hcp-0.8.0/bin/hcp version
       > failed to configure version checker: failed expanding HCP config directory path "~/.config/hcp/version_check_state.json": exec: "getent": executable file not found in $PATH
       > failed to instantiate HCP config: failed to resolve hcp's credential path: failed to resolve hcp's credential directory path: exec: "getent": executable file not found in $PATH
       For full logs, run 'nix log /nix/store/mkvvqzqmcn9xspbl4g5q1absgwnc0ikl-hcp-0.8.0.drv'.

Checking $out/bin/hcp version in postInstall. It looks like it tries to check for newer versions.

> failed to check for new version: failed to list recent releases: Get "https://api.releases.hashicorp.com/v1/releases/hcp": dial tcp: lookup api.rele
ases.hashicorp.com on [::1]:53: read udp [::1]:40251->[::1]:53: read: connection refused
> hcp v0.8.0 go1.23.4 amd64

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just patch it out

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v doesn't change anything. It looks if the version is a substring in the output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just patch it out

Could you please link some documentation or examples? Still new to Nix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically you can either replace stuff with substituteInPlace on postPatch or make a patch file and add to the patches list. It will be applied automatically. There are plenty of examples in nixpkgs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I gave it a close look but that version checker is embedded in a lot of the code and I couldn't find a good way to patch it out. Happy to take any more suggestions, moving on from this otherwise

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jan 2, 2025
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jan 2, 2025
@lucasew
Copy link
Contributor

lucasew commented Jan 2, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 370162


x86_64-linux

✅ 1 package built:
  • hcp

@lucasew
Copy link
Contributor

lucasew commented Jan 3, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 370162


x86_64-linux

✅ 1 package built:
  • hcp

@ethancedwards8
Copy link
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 370162


aarch64-darwin

✅ 1 package built:
  • hcp

Copy link
Member

@ethancedwards8 ethancedwards8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@wegank wegank added the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Jan 7, 2025
@lucasew
Copy link
Contributor

lucasew commented Jan 7, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 370162


x86_64-linux

✅ 1 package built:
  • hcp

Comment on lines 15 to 16
repo = pname;
rev = "v${version}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
repo = pname;
rev = "v${version}";
repo = "hcp";
tag = "v${version}";

Avoid using pname here: #277994
tag is the new recommended argument. rev should only be used for specific commits.

Copy link
Contributor Author

@dbreyfogle dbreyfogle Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repo = pname; did feel a bit awkward to me but it was suggested by another reviewer. Thanks for clearing it up with the linked issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah their two suggestions were exactly against current recommendations.

export HOME=$TMPDIR
'';

passthru.updateScript = gitUpdater { rev-prefix = "v"; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but I think the gitUpdater does not update the vendorHash.

Probably the nix-update-script could be used, I think it has a different parameter for version prefixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I think nix-update-script is a better fit here after reading through the documentation.

meta = {
description = "HCP Command-Line Interface";
homepage = "https://github.com/hashicorp/hcp";
changelog = "https://github.com/hashicorp/hcp/raw/v${version}/CHANGELOG.md";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also https://github.com/hashicorp/hcp/releases/tag/v${version} which is more common in nixpkgs.

One shows all changes, the other only changes in that version. Either is fine I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to https://github.com/hashicorp/hcp/releases/tag/v${version}. Seems more concise anyway.

@wegank wegank removed the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Jan 22, 2025
@FliegendeWurst FliegendeWurst merged commit 5544e59 into NixOS:master Jan 22, 2025
25 of 27 checks passed
@getchoo getchoo added the backport release-24.11 Backport PR automatically label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 12. first-time contribution This PR is the author's first one; please be gentle! backport release-24.11 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants