Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 112 lines 2.7 kB view raw
1{ 2 lib, 3 stdenv, 4 buildGoModule, 5 fetchFromGitHub, 6 buildPackages, 7 installShellFiles, 8 versionCheckHook, 9 makeWrapper, 10 enableCmount ? true, 11 fuse, 12 fuse3, 13 macfuse-stubs, 14 librclone, 15 nix-update-script, 16}: 17 18buildGoModule rec { 19 pname = "rclone"; 20 version = "1.70.3"; 21 22 outputs = [ 23 "out" 24 "man" 25 ]; 26 27 src = fetchFromGitHub { 28 owner = "rclone"; 29 repo = "rclone"; 30 tag = "v${version}"; 31 hash = "sha256-3MQyziA+Xq8oSOvex4WeeXs8rPDOcSkLHUH0Fcg8ENs="; 32 }; 33 34 vendorHash = "sha256-/A9Sq7KlHitqHxvElVMQtuXUWhweiB0ukut7AJYaJHw="; 35 36 subPackages = [ "." ]; 37 38 nativeBuildInputs = [ 39 installShellFiles 40 makeWrapper 41 ]; 42 43 buildInputs = lib.optional enableCmount ( 44 if stdenv.hostPlatform.isDarwin then macfuse-stubs else fuse 45 ); 46 47 tags = lib.optionals enableCmount [ "cmount" ]; 48 49 ldflags = [ 50 "-s" 51 "-w" 52 "-X github.com/rclone/rclone/fs.Version=${src.tag}" 53 ]; 54 55 postConfigure = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 56 substituteInPlace vendor/github.com/winfsp/cgofuse/fuse/host_cgo.go \ 57 --replace-fail '"libfuse.so.2"' '"${lib.getLib fuse}/lib/libfuse.so.2"' 58 ''; 59 60 postInstall = 61 let 62 rcloneBin = 63 if stdenv.buildPlatform.canExecute stdenv.hostPlatform then 64 "$out" 65 else 66 lib.getBin buildPackages.rclone; 67 in 68 '' 69 installManPage rclone.1 70 for shell in bash zsh fish; do 71 ${rcloneBin}/bin/rclone genautocomplete $shell rclone.$shell 72 installShellCompletion rclone.$shell 73 done 74 75 # filesystem helpers 76 ln -s $out/bin/rclone $out/bin/rclonefs 77 ln -s $out/bin/rclone $out/bin/mount.rclone 78 '' 79 + 80 lib.optionalString (enableCmount && !stdenv.hostPlatform.isDarwin) 81 # use --suffix here to ensure we don't shadow /run/wrappers/bin/fusermount3, 82 # as the setuid wrapper is required as non-root on NixOS. 83 '' 84 wrapProgram $out/bin/rclone \ 85 --suffix PATH : "${lib.makeBinPath [ fuse3 ]}" 86 ''; 87 88 nativeInstallCheckInputs = [ 89 versionCheckHook 90 ]; 91 doInstallCheck = true; 92 versionCheckProgram = "${placeholder "out"}/bin/${meta.mainProgram}"; 93 versionCheckProgramArg = "version"; 94 95 passthru = { 96 tests = { 97 inherit librclone; 98 }; 99 updateScript = nix-update-script { }; 100 }; 101 102 meta = { 103 description = "Command line program to sync files and directories to and from major cloud storage"; 104 homepage = "https://rclone.org"; 105 changelog = "https://github.com/rclone/rclone/blob/v${version}/docs/content/changelog.md"; 106 license = lib.licenses.mit; 107 mainProgram = "rclone"; 108 maintainers = with lib.maintainers; [ 109 SuperSandro2000 110 ]; 111 }; 112}