2023-03-12 22:13:22 +01:00
|
|
|
{ lib
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
|
|
|
, stdenv
|
|
|
|
, darwin
|
|
|
|
, unixtools
|
|
|
|
}:
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "halp";
|
2023-06-17 19:25:01 +02:00
|
|
|
version = "0.1.7";
|
2023-03-12 22:13:22 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "orhun";
|
|
|
|
repo = "halp";
|
|
|
|
rev = "v${version}";
|
2023-06-17 19:25:01 +02:00
|
|
|
hash = "sha256-SeBponGeQWKjbiS4GL8YA7y92BqLL+ja6ZSKAI3CeRM=";
|
2023-03-12 22:13:22 +01:00
|
|
|
};
|
|
|
|
|
2023-06-17 19:25:01 +02:00
|
|
|
cargoHash = "sha256-/mzbLsIc0PW5yx/m9eq3IWYM6i1MKvmOY+17/Bwjguk=";
|
2023-03-12 22:13:22 +01:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
# patch tests to point to the correct target directory
|
|
|
|
./fix-target-dir.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.Security
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
unixtools.script
|
|
|
|
];
|
|
|
|
|
|
|
|
# tests are failing on darwin
|
|
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
|
|
|
|
checkFlags = [
|
|
|
|
# requires internet access
|
|
|
|
"--skip=helper::docs::cheat::tests::test_fetch_cheat_sheet"
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/helper/args/mod.rs \
|
lib.systems: elaborate Rust metadata
We need this stuff to be available in lib so make-derivation.nix can
access it to construct the Meson cross file.
This has a couple of other advantages:
- It makes Rust less special. Now figuring out what Rust calls a
platform is the same as figuring out what Linux or QEMU call it.
- We can unify the schema used to define Rust targets, and the schema
used to access those values later. Just like you can set "config"
or "system" in a platform definition, and then access those same
keys on the elaborated platform, you can now set "rustcTarget" in
your crossSystem, and then access "stdenv.hostPlatform.rustcTarget"
in your code.
"rustcTarget", "rustcTargetSpec", "cargoShortTarget", and
"cargoEnvVarTarget" have the "rustc" and "cargo" prefixes because
these are not exposed to code by the compiler, and are not
standardized. The arch/os/etc. variables are all named to match the
forms in the Rust target spec JSON.
The new rust.target-family only takes a list, since we don't need to
worry about backwards compatibility when that name is used.
The old APIs are all still functional with no warning for now, so that
it's possible for external code to use a single API on both 23.05 and
23.11. We can introduce the warnings once 23.05 is EOL, and make them
hard errors when 23.11 is EOL.
2023-05-09 15:38:32 +02:00
|
|
|
--subst-var-by releaseDir target/${stdenv.hostPlatform.rust.rustcTargetSpec}/$cargoCheckType
|
2023-03-12 22:13:22 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
export NO_COLOR=1
|
|
|
|
export OUT_DIR=target
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p man completions
|
|
|
|
|
|
|
|
OUT_DIR=man $out/bin/halp-mangen
|
|
|
|
OUT_DIR=completions $out/bin/halp-completions
|
|
|
|
|
|
|
|
installManPage man/halp.1
|
|
|
|
installShellCompletion \
|
|
|
|
completions/halp.{bash,fish} \
|
|
|
|
--zsh completions/_halp
|
|
|
|
|
|
|
|
rm $out/bin/halp-{completions,mangen,test}
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A CLI tool to get help with CLI tools";
|
|
|
|
homepage = "https://github.com/orhun/halp";
|
|
|
|
changelog = "https://github.com/orhun/halp/blob/${src.rev}/CHANGELOG.md";
|
|
|
|
license = with licenses; [ asl20 mit ];
|
|
|
|
maintainers = with maintainers; [ figsoda ];
|
|
|
|
};
|
|
|
|
}
|