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

azure-cli: install completions for all shells #346715

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

maxbrunet
Copy link
Member

This switches to use register-python-argcomplete directly to generate and install the completion similarly to other Python tools like pipx.

The az.completion.sh script is not the actual completion, but runs eval: https://github.com/Azure/azure-cli/blob/azure-cli-2.60.0/src/azure-cli/az.completion.sh#L11

The previous state did not autoload for zsh and missed the installation for fish.

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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

@SFrijters
Copy link
Member

For me this breaks cross compilation nix build .#pkgsCross.aarch64-multiplatform.azure-cli -L in new and interesting ways: generating the autocompletions recursively spawns default-builder.sh processes until OOM. This is after applying a workaround described in #338231 to even get to that point so I'm not sure if this is important at the moment. Maybe consider guarding the completions behind lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) or similar.

@maxbrunet
Copy link
Member Author

Thank you @SFrijters for giving this a try, I have added the canExecute condition

Copy link
Contributor

@katexochen katexochen left a comment

Choose a reason for hiding this comment

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

Validated shell completion still works on x86_64-linux with bash, change looks good to me.
Didn't investigate further the cross-build issue.

Copy link
Member

@ulrikstrid ulrikstrid left a comment

Choose a reason for hiding this comment

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

Changes looks good, if @SFrijters can confirm that cross-builds works we can merge this.

@SFrijters
Copy link
Member

Yep, it skips the completions, which is better than getting stuck completely.

@h7x4 h7x4 merged commit a97373a into NixOS:master Oct 8, 2024
28 checks passed
@SFrijters
Copy link
Member

FWIW, I looked into this a bit more and the problem seems to be that the register-python-argcomplete that is added to nativeBuildInputs is the host version, not the build version (in my case /nix/store/dfkxar40cwydm4dvap0v0093ws6klahy-python3.12-argcomplete-3.4.0-aarch64-unknown-linux-gnu/bin/register-python-argcomplete). If I replace py.pkgs.argcomplete -> buildPackages.python3Packages.argcomplete it finds /nix/store/k6pyxc68js2zrmqprg1w47i2xxk2mxl2-python3.12-argcomplete-3.4.0/bin/register-python-argcomplete and the completions are generated correctly in cross.

I don't understand why this is the case however; if I look at for example nixpkgs-review, which is also a Python package that uses register-python-argcomplete, just putting it into the nativeBuildInputs is enough. I assume something happens in the complex layering of the Azure packages in particular.

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

Successfully merging this pull request may close these issues.

6 participants