2021-02-05 17:12:51 +00:00
|
|
|
{
|
|
|
|
# general
|
|
|
|
lib
|
2022-04-15 01:41:22 +00:00
|
|
|
, resholve
|
2021-02-05 17:12:51 +00:00
|
|
|
, bash
|
|
|
|
, doCheck ? true
|
|
|
|
, doInstallCheck ? true
|
|
|
|
# variant-specific
|
|
|
|
, variant
|
|
|
|
, version
|
|
|
|
, branch
|
|
|
|
, src
|
|
|
|
, fake ? false
|
|
|
|
, keep
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
# extracting this so that it's trivial to test in other shells
|
|
|
|
installCheck = shell:
|
|
|
|
''
|
|
|
|
echo "testing bashup.events in ${shell}"
|
|
|
|
${shell} <<'EOF'
|
|
|
|
source $out/bin/bashup.events
|
|
|
|
neat(){
|
|
|
|
echo $0: Hi from event \'test event\'. I can have both $1 and $2 arguments.
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
event on "test event" @2 neat curried
|
|
|
|
echo event registered
|
|
|
|
event emit "test event" runtime
|
|
|
|
exit 1 # fail if emitting event didn't exit clean
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
2022-04-15 01:41:22 +00:00
|
|
|
resholve.mkDerivation rec {
|
2021-02-05 17:12:51 +00:00
|
|
|
# bashup.events doesn't version yet but it has two variants with
|
|
|
|
# differing features/performance characteristics:
|
|
|
|
# - branch master: a variant for bash 3.2+
|
|
|
|
# - branch bash44: a variant for bash 4.4+
|
|
|
|
pname = "bashup-events${variant}-unstable";
|
|
|
|
# should be YYYY-MM-DD
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-03-09 03:18:52 +00:00
|
|
|
runHook preInstall
|
2021-02-05 17:12:51 +00:00
|
|
|
install -Dt $out/bin bashup.events
|
2021-03-09 03:18:52 +00:00
|
|
|
runHook postInstall
|
2021-02-05 17:12:51 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
inherit doCheck;
|
2021-12-19 01:06:50 +00:00
|
|
|
checkInputs = [ bash ];
|
2021-02-05 17:12:51 +00:00
|
|
|
|
|
|
|
checkPhase = ''
|
2021-03-09 03:18:52 +00:00
|
|
|
runHook preCheck
|
2021-02-05 17:12:51 +00:00
|
|
|
${bash}/bin/bash -n ./bashup.events
|
|
|
|
${bash}/bin/bash ./bashup.events
|
2021-03-09 03:18:52 +00:00
|
|
|
runHook postCheck
|
2021-02-05 17:12:51 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
solutions = {
|
|
|
|
events = {
|
|
|
|
inputs = [ ];
|
|
|
|
interpreter = "none";
|
|
|
|
scripts = [ "bin/bashup.events" ];
|
|
|
|
inherit keep;
|
|
|
|
} // lib.optionalAttrs (lib.isAttrs fake) { inherit fake; };
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit doInstallCheck;
|
|
|
|
installCheckInputs = [ bash ];
|
2021-03-09 03:18:52 +00:00
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
${installCheck "${bash}/bin/bash"}
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
2021-02-05 17:12:51 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
inherit branch;
|
|
|
|
description = "An event listener/callback API for creating extensible bash programs";
|
|
|
|
homepage = "https://github.com/bashup/events";
|
|
|
|
license = licenses.cc0;
|
|
|
|
maintainers = with maintainers; [ abathur ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|