2023-02-20 22:58:12 +01:00
|
|
|
{ lib
|
2021-11-22 01:47:16 +01:00
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
2023-02-20 22:58:12 +01:00
|
|
|
, pkg-config
|
2021-11-22 01:47:16 +01:00
|
|
|
, withNativeTls ? true
|
2023-02-20 22:58:12 +01:00
|
|
|
, stdenv
|
2021-11-22 01:47:16 +01:00
|
|
|
, Security
|
2023-02-20 22:58:12 +01:00
|
|
|
, openssl
|
|
|
|
}:
|
2021-02-13 00:43:13 +01:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "xh";
|
2023-02-20 22:58:12 +01:00
|
|
|
version = "0.18.0";
|
2021-02-13 00:43:13 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ducaale";
|
|
|
|
repo = "xh";
|
|
|
|
rev = "v${version}";
|
2023-02-20 22:58:12 +01:00
|
|
|
sha256 = "sha256-2qZ+FGc8Y8HLJaQluVv036NG77lvaqsc3I5cmkD+r/M=";
|
2021-02-13 00:43:13 +01:00
|
|
|
};
|
|
|
|
|
2023-02-20 22:58:12 +01:00
|
|
|
cargoSha256 = "sha256-0lPEZ8Th3PAw6AEnb+ciKMhi5wysFCvYwiHd9/o8VVc=";
|
2021-11-22 01:47:16 +01:00
|
|
|
|
|
|
|
buildFeatures = lib.optional withNativeTls "native-tls";
|
2021-02-13 00:43:13 +01:00
|
|
|
|
2021-05-24 04:22:43 +02:00
|
|
|
nativeBuildInputs = [ installShellFiles pkg-config ];
|
2021-03-21 04:35:48 +01:00
|
|
|
|
2021-11-22 01:47:16 +01:00
|
|
|
buildInputs = lib.optionals withNativeTls
|
2023-02-20 22:58:12 +01:00
|
|
|
(if stdenv.isDarwin then [ Security ] else [ openssl ]);
|
2021-03-21 04:35:48 +01:00
|
|
|
|
|
|
|
# Get openssl-sys to use pkg-config
|
|
|
|
OPENSSL_NO_VENDOR = 1;
|
2021-02-13 00:43:13 +01:00
|
|
|
|
2021-05-24 04:22:43 +02:00
|
|
|
postInstall = ''
|
2023-02-20 22:58:12 +01:00
|
|
|
installShellCompletion \
|
|
|
|
completions/xh.{bash,fish} \
|
2021-05-24 04:22:43 +02:00
|
|
|
--zsh completions/_xh
|
|
|
|
|
2022-03-24 21:51:00 +01:00
|
|
|
installManPage doc/xh.1
|
|
|
|
ln -s $out/share/man/man1/xh.1 $out/share/man/man1/xhs.1
|
|
|
|
|
|
|
|
install -m444 -Dt $out/share/doc/xh README.md CHANGELOG.md
|
|
|
|
|
2021-05-24 04:22:43 +02:00
|
|
|
ln -s $out/bin/xh $out/bin/xhs
|
|
|
|
'';
|
2021-02-13 00:43:13 +01:00
|
|
|
|
2021-03-21 04:35:48 +01:00
|
|
|
# Nix build happens in sandbox without internet connectivity
|
|
|
|
# disable tests as some of them require internet due to nature of application
|
|
|
|
doCheck = false;
|
2021-02-13 00:43:13 +01:00
|
|
|
doInstallCheck = true;
|
|
|
|
postInstallCheck = ''
|
|
|
|
$out/bin/xh --help > /dev/null
|
2021-05-24 04:22:43 +02:00
|
|
|
$out/bin/xhs --help > /dev/null
|
2021-02-13 00:43:13 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2021-05-24 04:22:43 +02:00
|
|
|
description = "Friendly and fast tool for sending HTTP requests";
|
2021-02-13 00:43:13 +01:00
|
|
|
homepage = "https://github.com/ducaale/xh";
|
2021-02-15 10:45:36 +01:00
|
|
|
changelog = "https://github.com/ducaale/xh/blob/v${version}/CHANGELOG.md";
|
2021-02-13 00:43:13 +01:00
|
|
|
license = licenses.mit;
|
2023-02-20 22:58:12 +01:00
|
|
|
maintainers = with maintainers; [ figsoda payas ];
|
2021-02-13 00:43:13 +01:00
|
|
|
};
|
|
|
|
}
|