1{
2 lib,
3 stdenv,
4 fetchurl,
5
6 # Runtime script dependencies
7 coreutils,
8 getent,
9 gnugrep,
10 gnused,
11 gnutar,
12 util-linux,
13
14 # Native build inputs
15 cmake,
16 findutils,
17 gettext,
18 mandoc,
19 makeWrapper,
20 perlPackages,
21
22 # Build inputs
23 boost,
24}:
25
26let
27 scripts-bin-path = lib.makeBinPath [
28 coreutils
29 getent
30 gnugrep
31 gnused
32 gnutar
33 util-linux
34 ];
35 upstream-version = "1.6.13";
36in
37stdenv.mkDerivation {
38 pname = "schroot";
39 version = "${upstream-version}-5";
40
41 src = fetchurl {
42 url = "https://codeberg.org/shelter/reschroot/archive/release/reschroot-${upstream-version}.tar.gz";
43 hash = "sha256-wF1qG7AhDUAeZSLu4sRl4LQ8bJj3EB1nH56e+Is6zPU=";
44 };
45
46 patches = map fetchurl (import ./debian-patches.nix) ++ [
47 ./no-setuid.patch
48 ./no-pam-service.patch
49 ./no-default-config.patch
50 ./fix-absolute-paths.patch
51 ./fix-boost-includes.patch
52 ];
53
54 nativeBuildInputs = [
55 cmake
56 findutils
57 gettext
58 mandoc
59 makeWrapper
60 perlPackages.Po4a
61 ];
62
63 buildInputs = [
64 boost
65 ];
66
67 cmakeFlags = [
68 (lib.cmakeFeature "CMAKE_INSTALL_LOCALSTATEDIR" "/var")
69 (lib.cmakeFeature "SCHROOT_SYSCONF_DIR" "/etc/schroot")
70 (lib.cmakeFeature "SCHROOT_CONF_SETUP_D" "${placeholder "out"}/etc/schroot/setup.d")
71 ];
72
73 postPatch = ''
74 # Substitute the path to the mount binary
75 substituteInPlace bin/schroot-mount/schroot-mount-main.cc \
76 --replace-fail "/bin/mount" "${util-linux}/bin/mount"
77 '';
78
79 postFixup = ''
80 # Make wrappers for all shell scripts used by schroot
81 # The wrapped script are put into a separate directory to not be run by schroot during setup
82 mkdir $out/etc/schroot/setup.d.wrapped
83 cd $out/etc/schroot/setup.d
84 find * -type f | while read -r file; do
85 mv "$file" $out/etc/schroot/setup.d.wrapped
86 makeWrapper "$out/etc/schroot/setup.d.wrapped/$file" "$file" --set PATH ${scripts-bin-path}
87 done
88
89 # Get rid of stuff that's (probably) not needed
90 rm -vrf $out/lib $out/include
91 '';
92
93 meta = {
94 description = "Lightweight virtualisation tool";
95 longDescription = ''
96 Schroot is a program that allows the user to run a command or a login shell in a chroot environment.
97 '';
98 homepage = "https://codeberg.org/shelter/reschroot";
99 changelog = "https://codeberg.org/shelter/reschroot/raw/tag/release/reschroot-${upstream-version}/NEWS";
100 mainProgram = "schroot";
101 maintainers = with lib.maintainers; [ bjsowa ];
102 license = lib.licenses.gpl3Plus;
103 platforms = lib.platforms.linux;
104 };
105}