Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 fetchFromGitHub,
4 makeWrapper,
5 nixosTests,
6
7 stdenv,
8 # Build inputs
9 btrfs-progs,
10 util-linux,
11 python3Packages,
12 # bees-service-wrapper
13 bash,
14 coreutils,
15}:
16
17stdenv.mkDerivation rec {
18 pname = "bees";
19 version = "0.11";
20
21 src = fetchFromGitHub {
22 owner = "Zygo";
23 repo = "bees";
24 rev = "v${version}";
25 hash = "sha256-qaiRWRd9+ElJ40QGOS3AxT2NvF3phQCyPnVz6RfTt8c=";
26 };
27
28 buildInputs = [
29 btrfs-progs # for btrfs/ioctl.h
30 util-linux # for uuid.h
31 ];
32
33 nativeBuildInputs = [
34 makeWrapper
35 python3Packages.markdown # documentation build
36 ];
37
38 preBuild = ''
39 git() { if [[ $1 = describe ]]; then echo ${version}; else command git "$@"; fi; }
40 export -f git
41 '';
42
43 postBuild = ''
44 unset -f git
45 '';
46
47 postInstall = ''
48 makeWrapper ${./bees-service-wrapper} "$out"/bin/bees-service-wrapper \
49 --prefix PATH : ${
50 lib.makeBinPath [
51 bash
52 coreutils
53 util-linux
54 btrfs-progs
55 ]
56 } \
57 --set beesd_bin "$out"/lib/bees/bees
58 '';
59
60 buildFlags = [
61 "ETC_PREFIX=/var/run/bees/configs"
62 ];
63
64 makeFlags = [
65 "SHELL=bash"
66 "PREFIX=$(out)"
67 "ETC_PREFIX=$(out)/etc"
68 "BEES_VERSION=${version}"
69 "SYSTEMD_SYSTEM_UNIT_DIR=$(out)/etc/systemd/system"
70 ];
71
72 passthru.tests = {
73 smoke-test = nixosTests.bees;
74 };
75
76 meta = with lib; {
77 homepage = "https://github.com/Zygo/bees";
78 description = "Block-oriented BTRFS deduplication service";
79 longDescription = "Best-Effort Extent-Same: bees finds not just identical files, but also identical extents within files that differ";
80 license = licenses.gpl3;
81 platforms = platforms.linux;
82 maintainers = with maintainers; [ chaduffy ];
83 };
84}