2022-03-31 18:11:26 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, makeWrapper, bat
|
2020-06-17 23:03:03 +00:00
|
|
|
# batdiff, batgrep, and batwatch
|
|
|
|
, coreutils
|
2021-05-07 17:57:50 +00:00
|
|
|
, getconf
|
2020-04-25 03:23:59 +00:00
|
|
|
, less
|
2022-11-06 00:42:05 +00:00
|
|
|
# tests
|
|
|
|
, bash
|
|
|
|
, zsh
|
|
|
|
, fish
|
2020-04-25 03:23:59 +00:00
|
|
|
# batgrep
|
|
|
|
, ripgrep
|
|
|
|
# prettybat
|
|
|
|
, withShFmt ? shfmt != null, shfmt ? null
|
|
|
|
, withPrettier ? nodePackages?prettier, nodePackages ? null
|
|
|
|
, withClangTools ? clang-tools != null, clang-tools ? null
|
|
|
|
, withRustFmt ? rustfmt != null, rustfmt ? null
|
|
|
|
# batwatch
|
|
|
|
, withEntr ? entr != null, entr ? null
|
2020-06-17 23:03:03 +00:00
|
|
|
# batdiff
|
|
|
|
, gitMinimal
|
gitAndTools: move everything to the top level
The comment at the top of git-and-tools/default.nix said:
/* All git-relates tools live here, in a separate attribute set so that users
* can get a fast overview over what's available.
but unfortunately that hasn't actually held up in practice.
Git-related packages have continued to be added to the top level, or
into gitAndTools, or sometimes both, basically at random, so having
gitAndTools is just confusing. In fact, until I looked as part of
working on getting rid of gitAndTools, one program (ydiff) was
packaged twice independently, once in gitAndTools and once at the top
level (I fixed this in 98c34901969).
So I think it's for the best if we move away from gitAndTools, and
just put all the packages it previously contained at the top level.
I've implemented this here by just making gitAndTools an alias for the
top level -- this saves having loads of lines in aliases.nix. This
means that people can keep referring to gitAndTools in their
configuration, but it won't be allowed to be used within Nixpkgs, and
it won't be presented to new users by e.g. nix search.
The only other change here that I'm aware of is that
appendToName "minimal" is not longer called on the default git
package, because doing that would have necessitated having a private
gitBase variable like before. I think it makes more sense not to do
that anyway, and reserve the "minimal" suffix only for gitMinimal.
2021-01-14 17:49:32 +00:00
|
|
|
, withDelta ? delta != null, delta ? null
|
2022-04-24 09:08:25 +00:00
|
|
|
# batman
|
|
|
|
, util-linux
|
2020-06-17 23:03:03 +00:00
|
|
|
}:
|
2020-04-25 03:23:59 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# Core derivation that all the others are based on.
|
|
|
|
# This includes the complete source so the per-script derivations can run the tests.
|
|
|
|
core = stdenv.mkDerivation rec {
|
|
|
|
pname = "bat-extras";
|
2023-03-21 17:27:11 +00:00
|
|
|
version = "2023.03.21";
|
2020-04-25 03:23:59 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "eth-p";
|
|
|
|
repo = pname;
|
2021-04-17 06:24:58 +00:00
|
|
|
rev = "v${version}";
|
2023-03-21 17:27:11 +00:00
|
|
|
sha256 = "sha256-0Ged4qBeGi0p29unXrnQjoxWc6Fcl2oJThxkfL+t50A=";
|
2020-04-25 03:23:59 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2020-06-17 23:03:03 +00:00
|
|
|
# bat needs to be in the PATH during building so EXECUTABLE_BAT picks it up
|
2022-03-31 18:11:26 +00:00
|
|
|
nativeBuildInputs = [ bat ];
|
2020-04-25 03:23:59 +00:00
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs --build test.sh test/shimexec .test-framework/bin/best.sh
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
bash ./build.sh --minify=none --no-verify
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Run the library tests as they don't have external dependencies
|
|
|
|
doCheck = true;
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [ bash fish zsh ] ++ (lib.optionals stdenv.isDarwin [ getconf ]);
|
2020-04-25 03:23:59 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
# test list repeats suites. Unique them
|
|
|
|
declare -A test_suites
|
|
|
|
while read -r action arg _; do
|
|
|
|
[[ "$action" == "test_suite" && "$arg" == lib_* ]] &&
|
|
|
|
test_suites+=(["$arg"]=1)
|
2022-11-06 00:42:05 +00:00
|
|
|
done <<<"$(./test.sh --compiled --list --porcelain)"
|
2020-04-25 03:23:59 +00:00
|
|
|
(( ''${#test_suites[@]} != 0 )) || {
|
|
|
|
echo "Couldn't find any library test suites"
|
|
|
|
exit 1
|
|
|
|
}
|
2022-11-06 00:42:05 +00:00
|
|
|
./test.sh --compiled $(printf -- "--suite %q\n" "''${!test_suites[@]}")
|
2020-04-25 03:23:59 +00:00
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
cp -a . $out
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
# A few random files have shebangs. Don't patch them, they don't make it into the final output.
|
|
|
|
# The per-script derivations will go ahead and patch the files they actually install.
|
|
|
|
dontPatchShebangs = true;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-04-25 03:23:59 +00:00
|
|
|
description = "Bash scripts that integrate bat with various command line tools";
|
|
|
|
homepage = "https://github.com/eth-p/bat-extras";
|
|
|
|
license = with licenses; [ mit ];
|
|
|
|
maintainers = with maintainers; [ bbigras lilyball ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
script =
|
|
|
|
name: # the name of the script
|
|
|
|
dependencies: # the tools we need to prefix onto PATH
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "${core.pname}-${name}";
|
|
|
|
inherit (core) version;
|
|
|
|
|
|
|
|
src = core;
|
|
|
|
|
2022-03-31 18:11:26 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-04-25 03:23:59 +00:00
|
|
|
# Make the dependencies available to the tests.
|
|
|
|
buildInputs = dependencies;
|
|
|
|
|
|
|
|
# Patch shebangs now because our tests rely on them
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs --host bin/${name}
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true; # we've already built
|
|
|
|
|
|
|
|
doCheck = true;
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [ bash fish zsh ] ++ (lib.optionals stdenv.isDarwin [ getconf ]);
|
2020-04-25 03:23:59 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
bash ./test.sh --compiled --suite ${name}
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp -p bin/${name} $out/bin/${name}
|
2021-01-15 09:19:50 +00:00
|
|
|
'' + lib.optionalString (dependencies != []) ''
|
2020-04-25 03:23:59 +00:00
|
|
|
wrapProgram $out/bin/${name} \
|
2021-01-15 09:19:50 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath dependencies}
|
2020-04-25 03:23:59 +00:00
|
|
|
'' + ''
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
# We already patched
|
|
|
|
dontPatchShebangs = true;
|
|
|
|
|
|
|
|
inherit (core) meta;
|
|
|
|
};
|
|
|
|
optionalDep = cond: dep:
|
|
|
|
assert cond -> dep != null;
|
2021-01-15 09:19:50 +00:00
|
|
|
lib.optional cond dep;
|
2020-04-25 03:23:59 +00:00
|
|
|
in
|
|
|
|
{
|
gitAndTools: move everything to the top level
The comment at the top of git-and-tools/default.nix said:
/* All git-relates tools live here, in a separate attribute set so that users
* can get a fast overview over what's available.
but unfortunately that hasn't actually held up in practice.
Git-related packages have continued to be added to the top level, or
into gitAndTools, or sometimes both, basically at random, so having
gitAndTools is just confusing. In fact, until I looked as part of
working on getting rid of gitAndTools, one program (ydiff) was
packaged twice independently, once in gitAndTools and once at the top
level (I fixed this in 98c34901969).
So I think it's for the best if we move away from gitAndTools, and
just put all the packages it previously contained at the top level.
I've implemented this here by just making gitAndTools an alias for the
top level -- this saves having loads of lines in aliases.nix. This
means that people can keep referring to gitAndTools in their
configuration, but it won't be allowed to be used within Nixpkgs, and
it won't be presented to new users by e.g. nix search.
The only other change here that I'm aware of is that
appendToName "minimal" is not longer called on the default git
package, because doing that would have necessitated having a private
gitBase variable like before. I think it makes more sense not to do
that anyway, and reserve the "minimal" suffix only for gitMinimal.
2021-01-14 17:49:32 +00:00
|
|
|
batdiff = script "batdiff" ([ less coreutils gitMinimal ] ++ optionalDep withDelta delta);
|
2020-06-17 23:03:03 +00:00
|
|
|
batgrep = script "batgrep" [ less coreutils ripgrep ];
|
2023-06-08 04:47:26 +00:00
|
|
|
batman = script "batman" (lib.optionals stdenv.isLinux [ util-linux ]);
|
2022-11-06 00:30:16 +00:00
|
|
|
batpipe = script "batpipe" [ less ];
|
2020-06-17 23:03:03 +00:00
|
|
|
batwatch = script "batwatch" ([ less coreutils ] ++ optionalDep withEntr entr);
|
|
|
|
prettybat = script "prettybat" ([]
|
2020-04-25 03:23:59 +00:00
|
|
|
++ optionalDep withShFmt shfmt
|
|
|
|
++ optionalDep withPrettier nodePackages.prettier
|
|
|
|
++ optionalDep withClangTools clang-tools
|
2020-06-17 23:03:03 +00:00
|
|
|
++ optionalDep withRustFmt rustfmt);
|
2020-04-25 03:23:59 +00:00
|
|
|
}
|