nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 100 lines 2.7 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 fetchzip, 6 autoPatchelfHook, 7 installShellFiles, 8 cpio, 9 xar, 10 versionCheckHook, 11}: 12 13let 14 inherit (stdenv.hostPlatform) system; 15 fetch = 16 srcPlatform: hash: extension: 17 let 18 args = { 19 url = "https://cache.agilebits.com/dist/1P/op2/pkg/v${version}/op_${srcPlatform}_v${version}.${extension}"; 20 inherit hash; 21 } 22 // lib.optionalAttrs (extension == "zip") { stripRoot = false; }; 23 in 24 if extension == "zip" then fetchzip args else fetchurl args; 25 26 pname = "1password-cli"; 27 version = "2.32.0"; 28 sources = rec { 29 aarch64-linux = fetch "linux_arm64" "sha256-7t8Ar6vF8lU3fPy5Gw9jtUkcx9gYKg6AFDB8/3QBvbk=" "zip"; 30 i686-linux = fetch "linux_386" "sha256-+KSi87muDH/A8LNH7iDPQC/CnZhTpvFNSw1cuewqaXI=" "zip"; 31 x86_64-linux = fetch "linux_amd64" "sha256-4I7lSey6I4mQ7dDtuOASnZzAItFYkIDZ8UMsqb0q5tE=" "zip"; 32 aarch64-darwin = 33 fetch "apple_universal" "sha256-PVSI/iYsjphNqs0DGQlzRhmvnwj4RHcNODE2nbQ8CO0=" 34 "pkg"; 35 x86_64-darwin = aarch64-darwin; 36 }; 37 platforms = builtins.attrNames sources; 38 mainProgram = "op"; 39in 40 41stdenv.mkDerivation { 42 inherit pname version; 43 src = 44 if (builtins.elem system platforms) then 45 sources.${system} 46 else 47 throw "Source for 1password-cli is not available for ${system}"; 48 49 nativeBuildInputs = [ 50 installShellFiles 51 versionCheckHook 52 ] 53 ++ lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook 54 ++ lib.optional stdenv.hostPlatform.isDarwin [ 55 xar 56 cpio 57 ]; 58 59 unpackPhase = lib.optionalString stdenv.hostPlatform.isDarwin '' 60 xar -xf $src 61 zcat op.pkg/Payload | cpio -i 62 ''; 63 64 installPhase = '' 65 runHook preInstall 66 install -D op $out/bin/op 67 runHook postInstall 68 ''; 69 70 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 71 HOME=$TMPDIR 72 installShellCompletion --cmd op \ 73 --bash <($out/bin/op completion bash) \ 74 --fish <($out/bin/op completion fish) \ 75 --zsh <($out/bin/op completion zsh) 76 ''; 77 78 dontStrip = stdenv.hostPlatform.isDarwin; 79 80 doInstallCheck = true; 81 82 versionCheckProgram = "${placeholder "out"}/bin/op"; 83 84 passthru = { 85 updateScript = ./update.sh; 86 }; 87 88 meta = { 89 description = "1Password command-line tool"; 90 homepage = "https://developer.1password.com/docs/cli/"; 91 downloadPage = "https://app-updates.agilebits.com/product_history/CLI2"; 92 maintainers = with lib.maintainers; [ 93 joelburget 94 khaneliman 95 ]; 96 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 97 license = lib.licenses.unfree; 98 inherit mainProgram platforms; 99 }; 100}