2023-02-22 10:55:15 +00:00
|
|
|
{ lib
|
2021-12-06 16:07:01 +00:00
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
2023-02-22 10:55:15 +00:00
|
|
|
, pkg-config
|
2021-12-06 16:07:01 +00:00
|
|
|
, withNativeTls ? true
|
2023-02-22 10:55:15 +00:00
|
|
|
, stdenv
|
2024-02-07 01:22:34 +00:00
|
|
|
, darwin
|
2023-02-22 10:55:15 +00:00
|
|
|
, openssl
|
|
|
|
}:
|
2021-02-13 14:23:35 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "xh";
|
2024-07-27 06:49:29 +00:00
|
|
|
version = "0.22.2";
|
2021-02-13 14:23:35 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ducaale";
|
|
|
|
repo = "xh";
|
|
|
|
rev = "v${version}";
|
2024-07-27 06:49:29 +00:00
|
|
|
sha256 = "sha256-FhhVodpIdcB+2s4AkFk6phvoXFLYll/CFJV2/lHS0ww=";
|
2021-02-13 14:23:35 +00:00
|
|
|
};
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
cargoHash = "sha256-P/OLzMpqWThrdCReWcPlVPGqVSjVD1veq3xL0TJ/soM=";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
buildFeatures = lib.optional withNativeTls "native-tls";
|
2021-02-13 14:23:35 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles pkg-config ];
|
2021-03-20 04:20:00 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildInputs = lib.optionals withNativeTls
|
2024-09-26 11:04:55 +00:00
|
|
|
(if stdenv.hostPlatform.isDarwin then [ darwin.apple_sdk.frameworks.SystemConfiguration ] else [ openssl ]);
|
2021-03-20 04:20:00 +00:00
|
|
|
|
|
|
|
# Get openssl-sys to use pkg-config
|
|
|
|
OPENSSL_NO_VENDOR = 1;
|
2021-02-13 14:23:35 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
postInstall = ''
|
2023-02-22 10:55:15 +00:00
|
|
|
installShellCompletion \
|
|
|
|
completions/xh.{bash,fish} \
|
2021-05-28 09:39:13 +00:00
|
|
|
--zsh completions/_xh
|
|
|
|
|
2022-03-30 09:31:56 +00: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-28 09:39:13 +00:00
|
|
|
ln -s $out/bin/xh $out/bin/xhs
|
|
|
|
'';
|
2021-02-13 14:23:35 +00:00
|
|
|
|
2021-03-20 04:20:00 +00: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 14:23:35 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
postInstallCheck = ''
|
|
|
|
$out/bin/xh --help > /dev/null
|
2021-05-28 09:39:13 +00:00
|
|
|
$out/bin/xhs --help > /dev/null
|
2021-02-13 14:23:35 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2021-05-28 09:39:13 +00:00
|
|
|
description = "Friendly and fast tool for sending HTTP requests";
|
2021-02-13 14:23:35 +00:00
|
|
|
homepage = "https://github.com/ducaale/xh";
|
2021-02-16 17:04:54 +00:00
|
|
|
changelog = "https://github.com/ducaale/xh/blob/v${version}/CHANGELOG.md";
|
2021-02-13 14:23:35 +00:00
|
|
|
license = licenses.mit;
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with maintainers; [ figsoda bhankas ];
|
2021-02-13 14:23:35 +00:00
|
|
|
};
|
|
|
|
}
|