1{
2 stdenv,
3 lib,
4 fetchurl,
5 fetchFromGitHub,
6}:
7
8let
9 version = "0.75";
10 sha256 = "1iajg55n47hqxcpdzmyq4g4aprx7bzxcp885i850h355k5vmf68r";
11 # Please don’t forget to update the docs:
12 # clone https://github.com/Profpatsch/cdb-docs
13 # and create a pull request with the result of running
14 # ./update <version>
15 # from the repository’s root folder.
16 docRepo = fetchFromGitHub {
17 owner = "Profpatsch";
18 repo = "cdb-docs";
19 rev = "359b6c55c9e170ebfc88f3f38face8ae2315eacb";
20 sha256 = "1y0ivviy58i0pmavhvrpznc4yjigjknff298gnw9rkg5wxm0gbbq";
21 };
22
23in
24stdenv.mkDerivation {
25 pname = "cdb";
26 inherit version;
27
28 src = fetchurl {
29 url = "https://cr.yp.to/cdb/cdb-${version}.tar.gz";
30 inherit sha256;
31 };
32
33 outputs = [
34 "bin"
35 "doc"
36 "out"
37 ];
38
39 env.NIX_CFLAGS_COMPILE = toString [
40 "-Wno-error=implicit-int"
41 "-Wno-error=implicit-function-declaration"
42 ];
43
44 postPatch = ''
45 # A little patch, borrowed from Archlinux AUR, borrowed from Gentoo Portage
46 sed -e 's/^extern int errno;$/#include <errno.h>/' -i error.h
47 '';
48
49 postInstall = ''
50 # don't use make setup, but move the binaries ourselves
51 mkdir -p $bin/bin
52 install -m 755 -t $bin/bin/ cdbdump cdbget cdbmake cdbmake-12 cdbmake-sv cdbstats cdbtest
53
54 # patch paths in scripts
55 function cdbmake-subst {
56 substituteInPlace $bin/bin/$1 \
57 --replace /usr/local/bin/cdbmake $bin/bin/cdbmake
58 }
59 cdbmake-subst cdbmake-12
60 cdbmake-subst cdbmake-sv
61
62 # docs
63 mkdir -p $doc/share/cdb
64 cp -r "${docRepo}/docs" $doc/share/cdb/html
65 '';
66
67 meta = {
68 homepage = "https://cr.yp.to/cdb.html";
69 license = lib.licenses.publicDomain;
70 maintainers = [ lib.maintainers.Profpatsch ];
71 platforms = lib.platforms.unix;
72 };
73}