Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 autoreconfHook,
7 bash,
8 buildPackages,
9 coreutils,
10 nixosTests,
11 perl,
12}:
13
14stdenv.mkDerivation rec {
15 pname = "fakechroot";
16 version = "2.20.1";
17
18 src = fetchFromGitHub {
19 owner = "dex4er";
20 repo = "fakechroot";
21 rev = version;
22 sha256 = "0xgnwazrmrg4gm30xjxdn6sx3lhqvxahrh6gmy3yfswxc30pmg86";
23 };
24
25 # Use patch from https://github.com/dex4er/fakechroot/pull/46 , remove once merged!
26 # Courtesy of one of our own, @copumpkin!
27 patches = [
28 (fetchpatch {
29 url = "https://github.com/dex4er/fakechroot/pull/46/commits/dcc0cfe3941e328538f9e62b2c0b15430d393ec1.patch";
30 sha256 = "1mk8j2njd94s7vf2wggi08xxxzx8dxrvdricl9cbspvkyp715w2m";
31 # Don't bother trying to reconcile conflicts for NEWS entries, as they will continue to occur
32 # and are uninteresting as well as unimportant for our purposes (since NEWS never leaves the build env).
33 excludes = [ "NEWS.md" ];
34 })
35
36 # glibc 2.33 compat (https://github.com/dex4er/fakechroot/pull/85/)
37 (fetchpatch {
38 url = "https://github.com/dex4er/fakechroot/commit/534e6d555736b97211523970d378dfb0db2608e9.patch";
39 sha256 = "sha256-bUlGJZvOSrATPt8bxGqU1UETTUD9V/HhJyA5ZxsOLQU=";
40 })
41 (fetchpatch {
42 url = "https://github.com/dex4er/fakechroot/commit/75d7e6fa191c11a791faff06a0de86eaa7801d05.patch";
43 sha256 = "sha256-vWN7zFkKlBd/F+h/66z21RiZqkSCn3UIzy9NHV7TYDg=";
44 })
45 (fetchpatch {
46 url = "https://github.com/dex4er/fakechroot/commit/693a3597ea7fccfb62f357503ff177bd3e3d5a89.patch";
47 sha256 = "sha256-bFXsT0hWocJFbtS1cpzo7oIy/x66iUw6QE1/cEoZ+3k=";
48 })
49 (fetchpatch {
50 url = "https://github.com/dex4er/fakechroot/commit/e7c1f3a446e594a4d0cce5f5d499c9439ce1d5c5.patch";
51 sha256 = "sha256-eX6kB4U1ZlXoRtkSVEIBTRjO/cTS/7z5a9S366DiRMg=";
52 })
53 # pass __readlinkat_chk buffer length
54 (fetchpatch {
55 url = "https://github.com/dex4er/fakechroot/pull/115/commits/15479d9436b534cee0115064bd8deb8d4ece9b8c.patch";
56 hash = "sha256-wMIZ3hW5XkRXQYBMADlN6kxhDSiEr84PGWBW+f4b4Ko=";
57 })
58 ];
59
60 postPatch = ''
61 for f in scripts/*; do
62 substituteInPlace $f \
63 --replace-quiet "@SHELL@" "${lib.getExe bash}" \
64 --replace-quiet "@CHROOT@" "${lib.getExe' coreutils "chroot"}" \
65 --replace-quiet "@ECHO@" "${lib.getExe' coreutils "echo"}" \
66 --replace-quiet "@ENV@" "${lib.getExe' coreutils "env"}" \
67 --replace-quiet "@MKFIFO@" "${lib.getExe' coreutils "mkfifo"}" \
68 --replace-quiet "@SEQ@" "${lib.getExe' coreutils "seq"}"
69 done
70 '';
71
72 nativeBuildInputs = [ autoreconfHook ];
73
74 buildInputs = [
75 bash
76 perl
77 ];
78
79 configureFlags = [
80 # pass in correct pod2man when cross-compiling
81 "ac_cv_path_POD2MAN=${lib.getExe' buildPackages.perl "pod2man"}"
82 ];
83
84 passthru = {
85 tests = {
86 # A lightweight *unit* test that exercises fakeroot and fakechroot together:
87 nixos-etc = nixosTests.etc.test-etc-fakeroot;
88 };
89 };
90
91 preFixup = ''
92 patchShebangs --host $out/bin
93 '';
94
95 meta = with lib; {
96 homepage = "https://github.com/dex4er/fakechroot";
97 description = "Give a fake chroot environment through LD_PRELOAD";
98 license = licenses.lgpl21;
99 maintainers = with maintainers; [ offline ];
100 platforms = platforms.linux;
101 };
102
103}