about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/bashup-events
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-01-26 18:06:19 +0000
committerAlyssa Ross <hi@alyssa.is>2021-01-26 18:21:18 +0000
commit7ac6743433dd45ceaead2ca96f6356dc0d064ce6 (patch)
treeb68ec89d7d2a8d2b6e6b1ff94ba26d6af4096350 /nixpkgs/pkgs/development/libraries/bashup-events
parentc5c7451dbef37b51f52792d6395a670ef5183d27 (diff)
parent891f607d5301d6730cb1f9dcf3618bcb1ab7f10e (diff)
downloadnixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar
nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.gz
nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.bz2
nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.lz
nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.xz
nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.zst
nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.zip
Merge commit '891f607d5301d6730cb1f9dcf3618bcb1ab7f10e'
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/bashup-events')
-rw-r--r--nixpkgs/pkgs/development/libraries/bashup-events/3.2.nix26
-rw-r--r--nixpkgs/pkgs/development/libraries/bashup-events/4.4.nix20
-rw-r--r--nixpkgs/pkgs/development/libraries/bashup-events/default.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/bashup-events/generic.nix83
4 files changed, 135 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/bashup-events/3.2.nix b/nixpkgs/pkgs/development/libraries/bashup-events/3.2.nix
new file mode 100644
index 000000000000..f7e88c382511
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/bashup-events/3.2.nix
@@ -0,0 +1,26 @@
+{ callPackage, fetchFromGitHub }:
+
+callPackage ./generic.nix {
+  variant = "3.2";
+  version = "2019-07-27";
+  branch = "master";
+  src = fetchFromGitHub {
+    owner = "bashup";
+    repo = "events";
+    rev = "83744c21bf720afb8325343674c62ab46a8f3d94";
+    hash = "sha256-0VDjd+1T1JBmSDGovWOOecUZmNztlwG32UcstfdigbI=";
+  };
+  fake = {
+    # Note: __ev.encode is actually defined, but it happens in a
+    # quoted arg to eval, which resholve currently doesn't (and may
+    # never) parse into. See abathur/resholve/issues/2.
+    function = [ "__ev.encode" ];
+  };
+  keep = {
+    # allow vars in eval
+    eval = [ "e" "f" "q" "r" ];
+    # allow vars executed as commands
+    "$f" = true;
+    "$n" = true;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/bashup-events/4.4.nix b/nixpkgs/pkgs/development/libraries/bashup-events/4.4.nix
new file mode 100644
index 000000000000..f880009ea71a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/bashup-events/4.4.nix
@@ -0,0 +1,20 @@
+{ callPackage, fetchFromGitHub }:
+
+callPackage ./generic.nix {
+  variant = "4.4";
+  version = "2020-04-04";
+  branch = "bash44";
+  src = fetchFromGitHub {
+    owner = "bashup";
+    repo = "events";
+    rev = "e97654f5602fc4e31083b27afa18dcc89b3e8296";
+    hash = "sha256-51OSIod3mEg3MKs4rrMgRcOimDGC+3UIr4Bl/cTRyGM=";
+  };
+  keep = {
+    # allow vars in eval
+    eval = [ "e" "bashup_ev" "n" ];
+    # allow vars executed as commands
+    "$f" = true;
+    "$n" = true;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/bashup-events/default.nix b/nixpkgs/pkgs/development/libraries/bashup-events/default.nix
new file mode 100644
index 000000000000..bcefdd0fcacf
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/bashup-events/default.nix
@@ -0,0 +1,6 @@
+{ callPackage }:
+
+{
+  bashup-events32 = callPackage ./3.2.nix { };
+  bashup-events44 = callPackage ./4.4.nix { };
+}
diff --git a/nixpkgs/pkgs/development/libraries/bashup-events/generic.nix b/nixpkgs/pkgs/development/libraries/bashup-events/generic.nix
new file mode 100644
index 000000000000..78ef4c2f3369
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/bashup-events/generic.nix
@@ -0,0 +1,83 @@
+{
+  # general
+  lib
+, callPackage
+, runCommand
+, resholvePackage
+, bash
+, shellcheck
+, 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
+resholvePackage rec {
+  # 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 = ''
+    install -Dt $out/bin bashup.events
+  '';
+
+  inherit doCheck;
+  checkInputs = [ shellcheck bash ];
+
+  # check based on https://github.com/bashup/events/blob/master/.dkrc
+  checkPhase = ''
+    SHELLCHECK_OPTS='-e SC2016,SC2145' ${shellcheck}/bin/shellcheck ./bashup.events
+    ${bash}/bin/bash -n ./bashup.events
+    ${bash}/bin/bash ./bashup.events
+  '';
+
+  solutions = {
+    events = {
+      inputs = [ ];
+      interpreter = "none";
+      scripts = [ "bin/bashup.events" ];
+      inherit keep;
+    } // lib.optionalAttrs (lib.isAttrs fake) { inherit fake; };
+  };
+
+  inherit doInstallCheck;
+  installCheckInputs = [ bash ];
+  installCheckPhase = installCheck "${bash}/bin/bash";
+
+  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;
+  };
+}