mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
45 lines
861 B
Nix
45 lines
861 B
Nix
{
|
|
lib,
|
|
stdenvNoCC,
|
|
logging-extractor,
|
|
fetchzip,
|
|
fetchurl,
|
|
name,
|
|
version,
|
|
url,
|
|
major,
|
|
sha256,
|
|
mode ? "json",
|
|
}: let
|
|
inherit (builtins) substring stringLength;
|
|
getExt = path: substring (stringLength path - 3) (-1) path;
|
|
extractor =
|
|
if ((getExt url) == "zip")
|
|
then fetchzip
|
|
else fetchurl;
|
|
ext =
|
|
if mode == "rust"
|
|
then "rs"
|
|
else "json";
|
|
cleanedMajor = builtins.replaceStrings ["."] ["_"] major;
|
|
in
|
|
stdenvNoCC.mkDerivation rec {
|
|
pname = "extractor-logs-${name}-${cleanedMajor}";
|
|
inherit version;
|
|
|
|
src = extractor {
|
|
inherit url sha256;
|
|
};
|
|
|
|
nativeBuildInputs = [logging-extractor];
|
|
|
|
buildPhase = ''
|
|
echo ${src}
|
|
logging-extractor . ${mode} > logs.${ext}
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp logs.* $out/${name}_${cleanedMajor}.${ext}
|
|
'';
|
|
}
|