Skip to content

Commit

Permalink
Merge pull request #327424 from d-brasher/init-revolver
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 authored Jul 28, 2024
2 parents 6a73382 + 51b146b commit 139855a
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
5 changes: 5 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4693,6 +4693,11 @@
githubId = 3179832;
name = "D. Bohdan";
};
d-brasher = {
github = "d-brasher";
githubId = 175485311;
name = "D. Brasher";
};
dbrgn = {
email = "[email protected]";
github = "dbrgn";
Expand Down
16 changes: 16 additions & 0 deletions pkgs/by-name/re/revolver/no-external-call.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Replace call to "revolver" with call to internal function.
Useful when "revolver" is not defined in PATH.
--- a/revolver
+++ b/revolver
@@ -255,9 +255,9 @@
###
function _revolver_demo() {
for style in "${(@k)_revolver_spinners[@]}"; do
- revolver --style $style start $style
+ _revolver --style $style start $style
sleep 2
- revolver stop
+ _revolver stop
done
}

94 changes: 94 additions & 0 deletions pkgs/by-name/re/revolver/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
zsh,
installShellFiles,
ncurses,
nix-update-script,
testers,
runCommand,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
pname = "revolver";
version = "0.2.4-unstable-2020-09-30";

src = fetchFromGitHub {
owner = "molovo";
repo = "revolver";
rev = "6424e6cb14da38dc5d7760573eb6ecb2438e9661";
hash = "sha256-2onqjtPIsgiEJj00oP5xXGkPZGQpGPVwcBOhmicqKcs=";
};

strictDeps = true;
doInstallCheck = true;

nativeBuildInputs = [ installShellFiles ];
buildInputs = [
zsh
ncurses
];
nativeInstallCheckInputs = [ zsh ];

patches = [ ./no-external-call.patch ];

postPatch = ''
substituteInPlace revolver \
--replace-fail "tput cols" "${ncurses}/bin/tput cols"
'';

installPhase = ''
runHook preInstall
install -D revolver $out/bin/revolver
runHook postInstall
'';

postInstall = ''
installShellCompletion --cmd revolver --zsh revolver.zsh-completion
'';

installCheckPhase = ''
runHook preInstallCheck
PATH=$PATH:$out/bin revolver --help
runHook postInstallCheck
'';

passthru = {
tests = {
demo = runCommand "revolver-demo" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } ''
export HOME="$TEMPDIR"
# Drop stdout, redirect stderr to stdout and check if it's not empty
exec 9>&1
echo "Running revolver demo..."
if [[ $(revolver demo 2>&1 1>/dev/null | tee >(cat - >&9)) ]]; then
exit 1
fi
echo "Demo done!"
mkdir $out
'';
version = testers.testVersion {
package = finalAttrs.finalPackage;
# Wrong '0.2.0' version in the code
version = "0.2.0";
};
};
updateScript = nix-update-script { };
};

meta = {
description = "Progress spinner for ZSH scripts";
homepage = "https://github.com/molovo/revolver";
downloadPage = "https://github.com/molovo/revolver/releases";
license = lib.licenses.mit;
mainProgram = "revolver";
inherit (zsh.meta) platforms;
maintainers = with lib.maintainers; [ d-brasher ];
};
})

0 comments on commit 139855a

Please sign in to comment.