1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7 buildPackages,
8}:
9let
10 version = "0.33.0";
11in
12buildGoModule {
13 pname = "csvtk";
14 inherit version;
15
16 src = fetchFromGitHub {
17 owner = "shenwei356";
18 repo = "csvtk";
19 tag = "v${version}";
20 hash = "sha256-Zacs1hw4pryVNxnrkLIoBNWo0jcKjtYdx6kW2LTFEIs=";
21 };
22
23 vendorHash = "sha256-T9flXxly3i8SKQlhp4AF2FNCqgcnGAHxv5b7nqzM3DI=";
24
25 nativeBuildInputs = [ installShellFiles ];
26
27 postInstall =
28 let
29 csvtkBin =
30 if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
31 "$out"
32 else
33 lib.getBin buildPackages.csvtk;
34 in
35 ''
36 for shell in bash zsh fish; do
37 ${csvtkBin}/bin/csvtk genautocomplete --shell $shell --file csvtk.$shell
38 installShellCompletion csvtk.$shell
39 done
40 '';
41
42 meta = {
43 description = "Cross-platform, efficient and practical CSV/TSV toolkit in Golang";
44 changelog = "https://github.com/shenwei356/csvtk/releases/tag/v${version}";
45 homepage = "https://github.com/shenwei356/csvtk";
46 license = lib.licenses.mit;
47 maintainers = with lib.maintainers; [ luftmensch-luftmensch ];
48 mainProgram = "csvtk";
49 };
50}