1{ fetchFromGitHub, stdenv, autoreconfHook, coreutils, gawk
2, configFile ? "all"
3
4# Kernel dependencies
5, kernel ? null
6}:
7
8with stdenv.lib;
9let
10 buildKernel = any (n: n == configFile) [ "kernel" "all" ];
11 buildUser = any (n: n == configFile) [ "user" "all" ];
12in
13
14assert any (n: n == configFile) [ "kernel" "user" "all" ];
15assert buildKernel -> kernel != null;
16
17stdenv.mkDerivation rec {
18 name = "spl-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
19
20 version = "0.6.5.7";
21
22 src = fetchFromGitHub {
23 owner = "zfsonlinux";
24 repo = "spl";
25 rev = "spl-${version}";
26 sha256 = "0i9ak4wqn444i6362xq5xl0msvcck8qqypp0fynrxq8mddzypwps";
27 };
28
29 patches = [ ./const.patch ./install_prefix.patch ];
30
31 nativeBuildInputs = [ autoreconfHook ];
32
33 hardeningDisable = [ "pic" ];
34
35 preConfigure = ''
36 substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
37 substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
38 substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
39 substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
40 '';
41
42 configureFlags = [
43 "--with-config=${configFile}"
44 ] ++ optionals buildKernel [
45 "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
46 "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
47 ];
48
49 enableParallelBuilding = true;
50
51 meta = {
52 description = "Kernel module driver for solaris porting layer (needed by in-kernel zfs)";
53
54 longDescription = ''
55 This kernel module is a porting layer for ZFS to work inside the linux
56 kernel.
57 '';
58
59 homepage = http://zfsonlinux.org/;
60 platforms = platforms.linux;
61 license = licenses.gpl2Plus;
62 maintainers = with maintainers; [ jcumming wizeman wkennington ];
63 broken = (kernel.features.grsecurity or false);
64 };
65}