Files
nixpkgs/pkgs/by-name/in/inflow/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

89 lines
2.4 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
runCommand,
inflow,
diffutils,
}:
stdenv.mkDerivation rec {
pname = "inflow";
version = "1.0.1";
src = fetchFromGitHub {
owner = "stephen-huan";
repo = "inflow";
rev = "v${version}";
hash = "sha256-xKUqkrPwITai8g6U1NiNieAip/AzISgFfFtvR30hLNk=";
};
buildPhase = ''
runHook preBuild
$CXX -Wall -Wpedantic -Wextra -O3 -o inflow inflow.cpp
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 inflow -t $out/bin
runHook postInstall
'';
passthru.tests = {
reflowWithLineLength =
runCommand "${pname}-test"
{
nativeBuildInputs = [ inflow ];
buildInputs = [ diffutils ];
}
''
cat <<EOF > input.txt
xxxxx xxx xxx xxxx xxxxxxxxx xx x xxxxxxxxx x xxxx xxxx xxxxxxx xxxxxxxx xxx
xxxxxxxxx xxxxxxxx xx xx xxxxx xxxxx xxxx xx x xxxx xx xxxxxxxx xxxxxxxx xxxx
xxx xxxx xxxx xxx xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxx xxx xxxxx xx xxxx x xxxx
xxxxxxxx xxxx xxxx xx xxxxx xxxx xxxxx xxxx xxxxxxxxx xxx xxxxxxxxxxx xxxxxx
xxx xxxxxxxxx xxxx xxxx xx x xx xxxx xxx xxxx xx xxx xxx xxxxxxxxxxx xxxx xxxxx
x xxxxx xxxxxxx xxxxxxx xx xx xxxxxx xx xxxxx
EOF
inflow 72 < input.txt > actual.txt
cat <<EOF > expected.txt
xxxxx xxx xxx xxxx xxxxxxxxx xx x xxxxxxxxx x xxxx xxxx xxxxxxx
xxxxxxxx xxx xxxxxxxxx xxxxxxxx xx xx xxxxx xxxxx xxxx xx x xxxx
xx xxxxxxxx xxxxxxxx xxxx xxx xxxx xxxx xxx xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx xxx xxxxx xx xxxx x xxxx xxxxxxxx xxxx xxxx xx xxxxx
xxxx xxxxx xxxx xxxxxxxxx xxx xxxxxxxxxxx xxxxxx xxx xxxxxxxxx
xxxx xxxx xx x xx xxxx xxx xxxx xx xxx xxx xxxxxxxxxxx xxxx xxxxx
x xxxxx xxxxxxx xxxxxxx xx xx xxxxxx xx xxxxx
EOF
if ! cmp --silent expected.txt actual.txt
then
echo "Error: actual.txt and expected.txt are different"
diff actual.txt expected.txt
exit 1
fi
touch $out
'';
};
meta = {
description = "Variance-optimal paragraph formatter";
homepage = "https://github.com/stephen-huan/inflow";
license = lib.licenses.unlicense;
mainProgram = "inflow";
maintainers = with lib.maintainers; [
fbrs
stephen-huan
];
platforms = lib.platforms.all;
};
}