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

rclone: install completions #79062

Merged
merged 1 commit into from Mar 5, 2020
Merged

rclone: install completions #79062

merged 1 commit into from Mar 5, 2020

Conversation

@marsam
Copy link
Contributor

@marsam marsam commented Feb 2, 2020

Motivation for this change

Release notes: https://forum.rclone.org/t/rclone-1-51-release/14114

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Copy link
Contributor

@danielfullmer danielfullmer left a comment

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
Comment on lines 22 to 24

This comment has been minimized.

@jonringer

jonringer Feb 2, 2020
Contributor

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

This comment has been minimized.

@marsam

marsam Feb 4, 2020
Author Contributor

unfortunately it does not work with buildGoPackage

This comment has been minimized.

@jonringer

jonringer Feb 4, 2020
Contributor

:(

@@ -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

This comment has been minimized.

@danielfullmer

danielfullmer Feb 4, 2020
Contributor

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.

This comment has been minimized.

@marsam

marsam Mar 5, 2020
Author Contributor

Sorry for the late response, I've applied your original suggestion

@marsam marsam force-pushed the marsam:update-rclone branch from c45dd1a to 08dc02a Mar 5, 2020
@marsam marsam changed the title rclone: 1.50.2 -> 1.51.0 rclone: install completions Mar 5, 2020
@marsam marsam requested a review from danielfullmer Mar 5, 2020
Copy link
Contributor

@danielfullmer danielfullmer left a comment

👍

@marsam marsam merged commit 93fd4b7 into NixOS:master Mar 5, 2020
15 checks passed
15 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A darwin-tested
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release-combined.nix -A tested
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
rclone on aarch64-linux Success
Details
rclone on x86_64-linux Success
Details
@marsam marsam deleted the marsam:update-rclone branch Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.