nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 which,
7 autoconf,
8 automake,
9 flex,
10 bison,
11 kernel,
12 glibc,
13 perl,
14 libtool_2,
15 libkrb5,
16}:
17
18let
19 inherit (import ./srcs.nix { inherit fetchurl; }) src version;
20
21 modDestDir = "$out/lib/modules/${kernel.modDirVersion}/extra/openafs";
22 kernelBuildDir = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
23
24in
25stdenv.mkDerivation {
26 pname = "openafs";
27 version = "${version}-${kernel.modDirVersion}";
28 inherit src;
29
30 patches = [
31 # Linux: Use struct kiocb * for aops write_begin/end
32 (fetchpatch {
33 url = "https://github.com/openafs/openafs/commit/a765a9ddd412c8d1e5cb0f5cf497a8606251811e.patch";
34 hash = "sha256-RkIAdXMvelnWs4YB3OMj6AIQlUbSqdKJpwc6wiSZzrM=";
35 })
36 # linux: remove implied def HAVE_LINUX_FILEMAP_GET_FOLIO
37 (fetchpatch {
38 url = "https://github.com/openafs/openafs/commit/c379ff006d8b7db425f7648321c549ab24919d92.patch";
39 hash = "sha256-fDtX3NhWIWupTArEauCM2rEaO3l8jWBVC5mAMil2+nU=";
40 })
41 # LINUX: Zero code on EEXIST in afs_linux_read_cache
42 (fetchpatch {
43 url = "https://github.com/openafs/openafs/commit/eb6753d93b930ad7d65772a9751117f6969a5e92.patch";
44 hash = "sha256-97/MdG9DrHEtOKCRLCTgl6ZEtqLUsaNs9LcAzcyrTF4=";
45 })
46 # Linux: mount_nodev removed, use new mount API
47 (fetchpatch {
48 url = "https://gerrit.openafs.org/changes/16646/revisions/93db75395149e1f0dbdc3a0572f58449dd9da98d/patch";
49 decode = "base64 -d";
50 hash = "sha256-5eYliZV3WPjbQ3WGvZuqzeu060MHRof2yozSWPn+Njg=";
51 })
52 # Linux: Rename LINUX_WRITEPAGES_USES_FOLIOS
53 (fetchpatch {
54 url = "https://gerrit.openafs.org/changes/16650/revisions/1e5801afe3069a9ca586c745ae1e26feb8f1048f/patch";
55 decode = "base64 -d";
56 hash = "sha256-qtqe64qhRwNBwfKkGhuEAKFDMFDirFxz9M0Wvtk+r1Q=";
57 })
58 # Linux: Don't use write_cache_pages for writepages
59 (fetchpatch {
60 url = "https://gerrit.openafs.org/changes/16648/revisions/652674cec6c6c7349709dc080b6a2db3253424e6/patch";
61 decode = "base64 -d";
62 hash = "sha256-5T4hOge3U5uk3NSFxocYEjgfXU1Se5FkQk2rCRZDlfU=";
63 })
64 ];
65
66 nativeBuildInputs = [
67 autoconf
68 automake
69 flex
70 libtool_2
71 perl
72 which
73 bison
74 ]
75 ++ kernel.moduleBuildDependencies;
76
77 buildInputs = [ libkrb5 ];
78
79 hardeningDisable = [ "pic" ];
80
81 configureFlags = [
82 "--with-linux-kernel-build=${kernelBuildDir}"
83 "--sysconfdir=/etc"
84 "--localstatedir=/var"
85 "--with-gssapi"
86 ];
87
88 preConfigure = ''
89 patchShebangs .
90 for i in `grep -l -R '/usr/\(include\|src\)' .`; do
91 echo "Patch /usr/include and /usr/src in $i"
92 substituteInPlace $i \
93 --replace "/usr/include" "${glibc.dev}/include" \
94 --replace "/usr/src" "${kernelBuildDir}"
95 done
96
97 ./regen.sh -q
98 '';
99
100 buildPhase = ''
101 make V=1 only_libafs
102 '';
103
104 installPhase = ''
105 mkdir -p ${modDestDir}
106 cp src/libafs/MODLOAD-*/libafs-${kernel.modDirVersion}.* ${modDestDir}/libafs.ko
107 xz -f ${modDestDir}/libafs.ko
108 '';
109
110 meta = {
111 description = "Open AFS client kernel module";
112 homepage = "https://www.openafs.org";
113 license = lib.licenses.ipl10;
114 platforms = lib.platforms.linux;
115 maintainers = with lib.maintainers; [
116 andersk
117 spacefrogg
118 ];
119 broken = kernel.isHardened;
120 };
121}