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