From 68fee72c52013e1128aef4a75ac8a6af9299927d Mon Sep 17 00:00:00 2001 From: Gustavo Coutinho de Souza Date: Fri, 24 Nov 2023 21:57:47 -0300 Subject: [PATCH] haredo: init at 1.0.5 --- pkgs/by-name/ha/haredo/package.nix | 71 ++++++++++++++++++++++++++++ pkgs/by-name/ha/haredo/setup-hook.sh | 69 +++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 pkgs/by-name/ha/haredo/package.nix create mode 100644 pkgs/by-name/ha/haredo/setup-hook.sh diff --git a/pkgs/by-name/ha/haredo/package.nix b/pkgs/by-name/ha/haredo/package.nix new file mode 100644 index 000000000000..277250170e5d --- /dev/null +++ b/pkgs/by-name/ha/haredo/package.nix @@ -0,0 +1,71 @@ +{ stdenv +, lib +, fetchFromSourcehut +, hare +, scdoc +, nix-update-script +}: +stdenv.mkDerivation (finalAttrs: { + pname = "haredo"; + version = "1.0.5"; + + outputs = [ "out" "man" ]; + + src = fetchFromSourcehut { + owner = "~autumnull"; + repo = "haredo"; + rev = finalAttrs.version; + hash = "sha256-gpui5FVRw3NKyx0AB/4kqdolrl5vkDudPOgjHc/IE4U="; + }; + + nativeBuildInputs = [ + hare + scdoc + ]; + + preBuild = '' + HARECACHE="$(mktemp -d --tmpdir harecache.XXXXXXXX)" + export HARECACHE + export PREFIX=${builtins.placeholder "out"} + ''; + + buildPhase = '' + runHook preBuild + + ./bootstrap.sh + + runHook postBuild + ''; + + checkPhase = '' + runHook preCheck + + ./bin/haredo test + + runHook postCheck + ''; + + installPhase = '' + runHook preInstall + + ./bootstrap.sh install + + runHook postInstall + ''; + + dontConfigure = true; + doCheck = true; + + setupHook = ./setup-hook.sh; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "A simple and unix-idiomatic build automator"; + homepage = "https://sr.ht/~autumnull/haredo/"; + license = lib.licenses.wtfpl; + maintainers = with lib.maintainers; [ onemoresuza ]; + mainProgram = "haredo"; + inherit (hare.meta) platforms badPlatforms; + }; +}) diff --git a/pkgs/by-name/ha/haredo/setup-hook.sh b/pkgs/by-name/ha/haredo/setup-hook.sh new file mode 100644 index 000000000000..44eb453087db --- /dev/null +++ b/pkgs/by-name/ha/haredo/setup-hook.sh @@ -0,0 +1,69 @@ +haredoBuildPhase() { + runHook preBuild + + local buildTargets jobs + read -ra buildTargets <<<"${haredoBuildTargets-}" + echoCmd "haredo build targets" "${buildTargets[@]}" + if [[ ! -v enableParallelBuilding || -n "${enableParallelBuilding-}" ]]; then + jobs="${NIX_BUILD_CORES}" + fi + haredo ${jobs:+"-j${jobs}"} "${buildTargets[@]}" + + runHook postBuild +} + +haredoCheckPhase() { + runHook preCheck + + local checkTargets jobs + + if [[ -n "${haredoCheckTargets:-}" ]]; then + read -ra checkTargets <<<"${haredoCheckTargets}" + else + for dofile in "check.do" "test.do"; do + [[ -r "${dofile}" ]] && { + checkTargets=("${dofile%".do"}") + break + } + done + fi + + if [[ -z "${checkTargets:-}" ]]; then + printf -- 'haredoCheckPhase ERROR: no check targets were found' 1>&2 + exit 1 + else + echoCmd "haredo check targets" "${checkTargets[@]}" + if [[ ! -v enableParallelChecking || -n "${enableParallelChecking-}" ]]; then + jobs="${NIX_BUILD_CORES}" + fi + haredo ${jobs:+"-j${jobs}"} "${checkTargets[@]}" + fi + + runHook postCheck +} + +haredoInstallPhase() { + runHook preInstall + + local installTargets jobs + read -ra installTargets <<<"${haredoInstallTargets:-"install"}" + echoCmd "haredo install targets" "${installTargets[@]}" + if [[ ! -v enableParallelInstalling || -n "${enableParallelInstalling-}" ]]; then + jobs="${NIX_BUILD_CORES}" + fi + haredo ${jobs:+"-j${jobs}"} "${installTargets[@]}" + + runHook postInstall +} + +if [[ -z "${dontUseHaredoBuild-}" && -z "${buildPhase-}" ]]; then + buildPhase="haredoBuildPhase" +fi + +if [[ -z "${dontUseHaredoCheck-}" && -z "${checkPhase-}" ]]; then + checkPhase="haredoCheckPhase" +fi + +if [[ -z "${dontUseHaredoInstall-}" && -z "${installPhase-}" ]]; then + installPhase="haredoInstallPhase" +fi