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