evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / in / inflow / package.nix
blob8545c48071b894109adc3eb7d5091899a45cb53d
1 { lib, stdenv, fetchFromGitHub, runCommand, inflow, diffutils }:
3 stdenv.mkDerivation rec {
4   pname = "inflow";
5   version = "1.0.1";
7   src = fetchFromGitHub {
8     owner = "stephen-huan";
9     repo = "inflow";
10     rev = "v${version}";
11     hash = "sha256-xKUqkrPwITai8g6U1NiNieAip/AzISgFfFtvR30hLNk=";
12   };
14   buildPhase = ''
15     runHook preBuild
17     $CXX -Wall -Wpedantic -Wextra -O3 -o inflow inflow.cpp
19     runHook postBuild
20   '';
22   installPhase = ''
23     runHook preInstall
25     install -Dm755 inflow -t $out/bin
27     runHook postInstall
28   '';
30   passthru.tests = {
31     reflowWithLineLength = runCommand "${pname}-test"
32       {
33         nativeBuildInputs = [ inflow ];
34         buildInputs = [ diffutils ];
35       } ''
36       cat <<EOF > input.txt
37       xxxxx xxx xxx xxxx xxxxxxxxx xx x xxxxxxxxx x xxxx xxxx xxxxxxx xxxxxxxx xxx
38       xxxxxxxxx xxxxxxxx xx xx xxxxx xxxxx xxxx xx x xxxx xx xxxxxxxx xxxxxxxx xxxx
39       xxx xxxx xxxx xxx xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxx xxx xxxxx xx xxxx x xxxx
40       xxxxxxxx xxxx xxxx xx xxxxx xxxx xxxxx xxxx xxxxxxxxx xxx xxxxxxxxxxx xxxxxx
41       xxx xxxxxxxxx xxxx xxxx xx x xx xxxx xxx xxxx xx xxx xxx xxxxxxxxxxx xxxx xxxxx
42       x xxxxx xxxxxxx xxxxxxx xx xx xxxxxx xx xxxxx
43       EOF
45       inflow 72 < input.txt > actual.txt
47       cat <<EOF > expected.txt
48       xxxxx xxx xxx xxxx xxxxxxxxx xx x xxxxxxxxx x xxxx xxxx xxxxxxx
49       xxxxxxxx xxx xxxxxxxxx xxxxxxxx xx xx xxxxx xxxxx xxxx xx x xxxx
50       xx xxxxxxxx xxxxxxxx xxxx xxx xxxx xxxx xxx xxxxxxxxxxxxxxxxxxx
51       xxxxxxxxxxxxx xxx xxxxx xx xxxx x xxxx xxxxxxxx xxxx xxxx xx xxxxx
52       xxxx xxxxx xxxx xxxxxxxxx xxx xxxxxxxxxxx xxxxxx xxx xxxxxxxxx
53       xxxx xxxx xx x xx xxxx xxx xxxx xx xxx xxx xxxxxxxxxxx xxxx xxxxx
54       x xxxxx xxxxxxx xxxxxxx xx xx xxxxxx xx xxxxx
55       EOF
57       if ! cmp --silent expected.txt actual.txt
58       then
59         echo "Error: actual.txt and expected.txt are different"
60         diff actual.txt expected.txt
61         exit 1
62       fi
64       touch $out
65     '';
66   };
68   meta = with lib; {
69     description = "Variance-optimal paragraph formatter";
70     homepage = "https://github.com/stephen-huan/inflow";
71     license = licenses.unlicense;
72     mainProgram = "inflow";
73     maintainers = with maintainers; [ fbrs ];
74     platforms = platforms.all;
75   };