nixos-configs/overlays/build-failures/bat-extras.nix

210 lines
5.1 KiB
Nix
Raw Normal View History

chore: update sources Flake Inputs: • Updated input 'ags': 'github:Aylur/ags' (2025-01-05) rev: 5527c3c07d92c11e04e7fd99d58429493dba7e3c → 'github:Aylur/ags' (2025-01-12) rev: 90db9b9fecc0f4228440d83107c6c745a35e7d77 • Updated input 'astal': 'github:Aylur/astal' (2025-01-10) rev: ef4f95608481414053ecdbe4de29bd86fb452813 → 'github:Aylur/astal' (2025-01-12) rev: 6fd7ae514af36ff9baf1209a2eeebd3a26cf94ce • Updated input 'custom-sidebar-src': 'github:elchininet/custom-sidebar' (2025-01-05) rev: f5a9a86adcbe68aeefea45e12294368d54fe8156 → 'github:elchininet/custom-sidebar' (2025-01-12) rev: dd69b17b383e6135a8198248292786b7839aef85 • Updated input 'hyprgrass': 'github:horriblename/hyprgrass' (2025-01-02) rev: bdfa960b97ac98ad9d05c908ee20e053e2942928 → 'github:horriblename/hyprgrass' (2025-01-09) rev: dcf43737772490f9dc755983f5c8ddda5f83ec5b • Updated input 'hyprland': 'github:hyprwm/Hyprland' (2025-01-06) rev: b9f110ef8726fcba2b4ee69856027731e73003a5 → 'github:hyprwm/Hyprland' (2025-01-12) rev: a6b263713a2b862ed41362082e2147e081934077 • Updated input 'hyprland-plugins': 'github:hyprwm/hyprland-plugins' (2025-01-05) rev: b6b31113ce84419c69ed575c22194e4023d2952a → 'github:hyprwm/hyprland-plugins' (2025-01-08) rev: b4c0fa3ebc6ccd1589dcd17904652223088efede • Updated input 'jovian': 'github:Jovian-Experiments/Jovian-NixOS' (2025-01-11) rev: 1ddf0b3bfe076fa50b84244e42a55b9234f96083 → 'github:Jovian-Experiments/Jovian-NixOS' (2025-01-12) rev: 54d7806eb668a28ab1dbdd25ee0caab6f8c62433 • Updated input 'material-rounded-theme-src': 'github:Nerwyn/material-rounded-theme' (2025-01-08) rev: 64b43de45e1e5bcfab8aa84f7b9dccd9764e027f → 'github:Nerwyn/material-rounded-theme' (2025-01-11) rev: 6d3b79a79b72f70c4a015dd7dbbf1c41a2b33a35 • Updated input 'nix-gaming': 'github:fufexan/nix-gaming' (2025-01-11) rev: 0e562d23a2df60788af3aeda21590032b416be7c → 'github:fufexan/nix-gaming' (2025-01-12) rev: f0bba32370e38a6ed18d7c5c741d23fe53e2d265 • Updated input 'nix-index-db': 'github:Mic92/nix-index-database' (2025-01-09) rev: a2200b499efa01ca8646173e94cdfcc93188f2b8 → 'github:Mic92/nix-index-database' (2025-01-12) rev: 271e5bd7c57e1f001693799518b10a02d1123b12 • Updated input 'nixpkgs': 'github:NixOS/nixpkgs' (2025-01-08) rev: bffc22eb12172e6db3c5dde9e3e5628f8e3e7912 → 'github:NixOS/nixpkgs' (2025-01-10) rev: 130595eba61081acde9001f43de3248d8888ac4a • Updated input 'nixpkgs-wayland': 'github:nix-community/nixpkgs-wayland' (2025-01-11) rev: 37553f5a9728a5ced261f0aa9c050056e7f61bde → 'github:nix-community/nixpkgs-wayland' (2025-01-12) rev: 2cb439411d17eb145a99536196f5ab11685268b8 • Updated input 'tuya-local-src': 'github:make-all/tuya-local' (2025-01-11) rev: 29def3abf990d04f311a0d4324d54aedc4b841c8 → 'github:make-all/tuya-local' (2025-01-12) rev: 627e07e5627da27ccc474bfe9cdb61f3126e0adb Docker Images: • rssbridge/rss-bridge latest: sha256:2f94bc58b926a9ae2efb62c2bd08723b22adceb47d5590be00b56dc05ba2a0e3 → sha256:f2ffb2127499e4c86f001ba5adaa86f80f5167ae4bcea6bdd11401eb0f769224 • ghcr.io/linuxserver/radarr latest: sha256:e633fc93b9e2cea959853d27c6acc1d0b2d1ed7db4a800f6f46fe5b217f13102 → sha256:dce7e81d08da67cf44437c7213d19faeef1323aa839712fbb53d1253ef94f93f
2025-01-12 14:28:44 -05:00
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
makeWrapper,
bat,
# batdiff, batgrep, and batwatch
coreutils,
getconf,
less,
# tests
bash,
zsh,
fish,
# 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,
# batdiff
gitMinimal,
withDelta ? delta != null,
delta ? null,
# batman
util-linux,
}: 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";
version = "2024.07.10";
src = fetchFromGitHub {
owner = "eth-p";
repo = "bat-extras";
rev = "v${version}";
hash = "sha256-6IRAKSy5f/WcQZBcJKVSweTjHLznzdxhsyx074bXnUQ=";
fetchSubmodules = true;
};
# bat needs to be in the PATH during building so EXECUTABLE_BAT picks it up
nativeBuildInputs = [bat];
dontConfigure = true;
patches = [
(fetchpatch {
url = "https://github.com/petrzjunior/nixpkgs/raw/80d08100fa04fdb0187f3a7a8667e12aa3614b5e/pkgs/tools/misc/bat-extras/disable-theme-tests.patch";
hash = "sha256-vBNMaJFwr9zTobvIRc5VljMPG3kVk07E+mNc1SJVyzg=";
})
];
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;
nativeCheckInputs =
[
bash
fish
zsh
]
++ (lib.optionals stdenv.hostPlatform.isDarwin [getconf]);
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)
done <<<"$(./test.sh --compiled --list --porcelain)"
(( ''${#test_suites[@]} != 0 )) || {
echo "Couldn't find any library test suites"
exit 1
}
./test.sh --compiled $(printf -- "--suite %q\n" "''${!test_suites[@]}")
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;
meta = with lib; {
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];
platforms = platforms.all;
};
};
script = name:
# the name of the script
dependencies:
# the tools we need to prefix onto PATH
stdenv.mkDerivation {
pname = name;
inherit (core) version;
src = core;
nativeBuildInputs = [makeWrapper];
# 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;
nativeCheckInputs =
[
bat
bash
fish
zsh
]
++ (lib.optionals stdenv.hostPlatform.isDarwin [getconf]);
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}
''
+ lib.optionalString (dependencies != []) ''
wrapProgram $out/bin/${name} \
--prefix PATH : ${lib.makeBinPath dependencies}
''
+ ''
runHook postInstall
'';
# We already patched
dontPatchShebangs = true;
meta =
core.meta
// {
mainProgram = name;
};
};
optionalDep = cond: dep:
assert cond -> dep != null;
lib.optional cond dep;
in {
batdiff = script "batdiff" (
[
less
coreutils
gitMinimal
]
++ optionalDep withDelta delta
);
batgrep = script "batgrep" [
less
coreutils
ripgrep
];
batman = script "batman" (lib.optionals stdenv.hostPlatform.isLinux [util-linux]);
batpipe = script "batpipe" [less];
batwatch = script "batwatch" (
[
less
coreutils
]
++ optionalDep withEntr entr
);
prettybat = script "prettybat" (
[]
++ optionalDep withShFmt shfmt
++ optionalDep withPrettier nodePackages.prettier
++ optionalDep withClangTools clang-tools
++ optionalDep withRustFmt rustfmt
);
}