1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 coreutils,
6 patsh,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "csvquote";
11 version = "0.1.5";
12
13 src = fetchFromGitHub {
14 owner = "dbro";
15 repo = "csvquote";
16 rev = "v${version}";
17 hash = "sha256-847JAoDEfA9K4LB8z9cqSw+GTImqmITBylB/4odLDb0=";
18 };
19
20 patches = [
21 # patch csvheader to use csvquote from the derivation
22 ./csvquote-path.patch
23 ];
24
25 nativeBuildInputs = [
26 patsh
27 ];
28
29 # needed for cross
30 buildInputs = [ coreutils ];
31
32 makeFlags = [
33 "BINDIR=$(out)/bin"
34 ];
35
36 preInstall = ''
37 mkdir -p "$out/bin"
38 '';
39
40 postInstall = ''
41 substituteAllInPlace $out/bin/csvheader
42 patsh $out/bin/csvheader -fs ${builtins.storeDir} --path "$HOST_PATH"
43 '';
44
45 meta = with lib; {
46 description = "Enables common unix utilities like cut, awk, wc, head to work correctly with csv data containing delimiters and newlines";
47 homepage = "https://github.com/dbro/csvquote";
48 license = licenses.mit;
49 maintainers = with maintainers; [ figsoda ];
50 platforms = platforms.all;
51 };
52}