fluffychat: 1.22.1 -> 1.23.0 (#364091)
[NixPkgs.git] / pkgs / by-name / in / inflow / package.nix
blob32416963105d55afee89a5938c925fbf3da15ade
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   runCommand,
6   inflow,
7   diffutils,
8 }:
10 stdenv.mkDerivation rec {
11   pname = "inflow";
12   version = "1.0.1";
14   src = fetchFromGitHub {
15     owner = "stephen-huan";
16     repo = "inflow";
17     rev = "v${version}";
18     hash = "sha256-xKUqkrPwITai8g6U1NiNieAip/AzISgFfFtvR30hLNk=";
19   };
21   buildPhase = ''
22     runHook preBuild
24     $CXX -Wall -Wpedantic -Wextra -O3 -o inflow inflow.cpp
26     runHook postBuild
27   '';
29   installPhase = ''
30     runHook preInstall
32     install -Dm755 inflow -t $out/bin
34     runHook postInstall
35   '';
37   passthru.tests = {
38     reflowWithLineLength =
39       runCommand "${pname}-test"
40         {
41           nativeBuildInputs = [ inflow ];
42           buildInputs = [ diffutils ];
43         }
44         ''
45           cat <<EOF > input.txt
46           xxxxx xxx xxx xxxx xxxxxxxxx xx x xxxxxxxxx x xxxx xxxx xxxxxxx xxxxxxxx xxx
47           xxxxxxxxx xxxxxxxx xx xx xxxxx xxxxx xxxx xx x xxxx xx xxxxxxxx xxxxxxxx xxxx
48           xxx xxxx xxxx xxx xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxx xxx xxxxx xx xxxx x xxxx
49           xxxxxxxx xxxx xxxx xx xxxxx xxxx xxxxx xxxx xxxxxxxxx xxx xxxxxxxxxxx xxxxxx
50           xxx xxxxxxxxx xxxx xxxx xx x xx xxxx xxx xxxx xx xxx xxx xxxxxxxxxxx xxxx xxxxx
51           x xxxxx xxxxxxx xxxxxxx xx xx xxxxxx xx xxxxx
52           EOF
54           inflow 72 < input.txt > actual.txt
56           cat <<EOF > expected.txt
57           xxxxx xxx xxx xxxx xxxxxxxxx xx x xxxxxxxxx x xxxx xxxx xxxxxxx
58           xxxxxxxx xxx xxxxxxxxx xxxxxxxx xx xx xxxxx xxxxx xxxx xx x xxxx
59           xx xxxxxxxx xxxxxxxx xxxx xxx xxxx xxxx xxx xxxxxxxxxxxxxxxxxxx
60           xxxxxxxxxxxxx xxx xxxxx xx xxxx x xxxx xxxxxxxx xxxx xxxx xx xxxxx
61           xxxx xxxxx xxxx xxxxxxxxx xxx xxxxxxxxxxx xxxxxx xxx xxxxxxxxx
62           xxxx xxxx xx x xx xxxx xxx xxxx xx xxx xxx xxxxxxxxxxx xxxx xxxxx
63           x xxxxx xxxxxxx xxxxxxx xx xx xxxxxx xx xxxxx
64           EOF
66           if ! cmp --silent expected.txt actual.txt
67           then
68             echo "Error: actual.txt and expected.txt are different"
69             diff actual.txt expected.txt
70             exit 1
71           fi
73           touch $out
74         '';
75   };
77   meta = with lib; {
78     description = "Variance-optimal paragraph formatter";
79     homepage = "https://github.com/stephen-huan/inflow";
80     license = licenses.unlicense;
81     mainProgram = "inflow";
82     maintainers = with maintainers; [ fbrs ];
83     platforms = platforms.all;
84   };