1{ fetchFromGitHub, stdenv, autoconf, automake, libtool, 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.4";
21
22 src = fetchFromGitHub {
23 owner = "zfsonlinux";
24 repo = "spl";
25 rev = "spl-${version}";
26 sha256 = "0k80xvl15ahbs0mylfl2bd5widxhngpf7dl6zq46s21wk0795jl4";
27 };
28
29 patches = [ ./const.patch ./install_prefix.patch ];
30
31 buildInputs = [ autoconf automake libtool ];
32
33 preConfigure = ''
34 ./autogen.sh
35
36 substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
37 substituteInPlace ./module/spl/spl-module.c --replace /bin/mknod mknod
38
39 substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
40 substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
41 substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
42 '';
43
44 configureFlags = [
45 "--with-config=${configFile}"
46 ] ++ optionals buildKernel [
47 "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
48 "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
49 ];
50
51 enableParallelBuilding = true;
52
53 meta = {
54 description = "Kernel module driver for solaris porting layer (needed by in-kernel zfs)";
55
56 longDescription = ''
57 This kernel module is a porting layer for ZFS to work inside the linux
58 kernel.
59 '';
60
61 homepage = http://zfsonlinux.org/;
62 platforms = platforms.linux;
63 license = licenses.gpl2Plus;
64 maintainers = with maintainers; [ jcumming wizeman wkennington ];
65 };
66}