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
rclone: install completions #79062
rclone: install completions #79062
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executing $bin/bin/rclone
in postInstall
would break cross compilation. Consider these changes:
I've tested these changes by building rclone
and also pkgsCross.aarch64-multiplatform.rclone
--- a/pkgs/applications/networking/sync/rclone/default.nix
+++ b/pkgs/applications/networking/sync/rclone/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildGoPackage, fetchFromGitHub }:
+{ stdenv, buildGoPackage, fetchFromGitHub, buildPackages }:
buildGoPackage rec {
pname = "rclone";
@@ -17,11 +17,15 @@ buildGoPackage rec {
outputs = [ "bin" "out" "man" ];
- postInstall = ''
+ postInstall = let
+ rcloneBin = if (stdenv.buildPlatform == stdenv.hostPlatform)
+ then "$bin"
+ else (stdenv.lib.getBin buildPackages.rclone);
+ in ''
install -D -m644 $src/rclone.1 $man/share/man/man1/rclone.1
mkdir -p $bin/share/zsh/site-functions $bin/share/bash-completion/completions/
- $bin/bin/rclone genautocomplete zsh $bin/share/zsh/site-functions/_rclone
- $bin/bin/rclone genautocomplete bash $bin/share/bash-completion/completions/rclone.bash
+ ${rcloneBin}/bin/rclone genautocomplete zsh $bin/share/zsh/site-functions/_rclone
+ ${rcloneBin}/bin/rclone genautocomplete bash $bin/share/bash-completion/completions/rclone.bash
'';
meta = with stdenv.lib; {
Other than that, LGTM
mkdir -p $bin/share/zsh/site-functions $bin/share/bash-completion/completions/ | ||
$bin/bin/rclone genautocomplete zsh $bin/share/zsh/site-functions/_rclone | ||
$bin/bin/rclone genautocomplete bash $bin/share/bash-completion/completions/rclone.bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want to use installShellCompletion
:
nativeBuildIinputs = [ installShellCompletion ];
$bin/bin/rclone genautocomplete zsh > _rclone
$bin/bin/rclone genautocomplete bash > rclone.bash
installShellCompletion _rclone rclone.bash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately it does not work with buildGoPackage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:(
@@ -19,6 +19,9 @@ buildGoPackage rec { | |||
|
|||
postInstall = '' | |||
install -D -m644 $src/rclone.1 $man/share/man/man1/rclone.1 | |||
mkdir -p $bin/share/zsh/site-functions/ $bin/share/bash-completion/completions/ | |||
$NIX_BUILD_TOP/go/bin/rclone genautocomplete zsh $bin/share/zsh/site-functions/_rclone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the same issue with cross-compilation. $NIX_BUILD_TOP/go/bin/rclone
is compiled for the host platform and wouldn't run on the build platform. Building pkgsCross.aarch64-multiplatform.rclone
produces this error:
/nix/store/7hqfwijjqda0p0ppdhm0b6i3xg5blgnr-stdenv-linux/setup: line 83: /build/go/bin/rclone: cannot execute binary file: Exec format error
I think you should conditionally use buildPackages.rclone
if stdenv.buildPlatform != stdenv.hostPlatform
like in the earlier suggested changes. For reference, note the similar code in pkgs/shells/zsh/default.nix
for generating autocomplete files in a cross-compatible way.
You can test with nix-build . -A pkgsCross.aarch64-multiplatform.rclone
--which doesn't take too long since most dependencies are already in the cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response, I've applied your original suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Motivation for this change
Release notes: https://forum.rclone.org/t/rclone-1-51-release/14114
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)