summary refs log tree commit diff
path: root/pkgs/os-specific/linux/aufs2/default.nix
blob: 6e87546c6a95a1178e942da9580f5ded15dc6523 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ stdenv, fetchgit, kernel, perl }:

let s = import ./src-for-default.nix; in

stdenv.mkDerivation {
  name = "${s.name}-${kernel.version}";

  src = fetchgit {
    inherit (s) url rev;
    sha256 = s.hash;
  };

  buildInputs = [ perl ];

  buildPhase = ''
    kernelVersion=$(cd ${kernel}/lib/modules && ls)
    kernelBuild=$(echo ${kernel}/lib/modules/$kernelVersion/source)
    tar xvfj ${kernel.src}
    kernelSource=$(echo $(pwd)/linux-*)
    cp -prd $kernelBuild/* $kernelSource

    # Looks like GCC3 and GCC4 protect stack differently
    # We do have the protection with recent GCC3 and GCC4, so override 
    # the check
    chmod u+w $kernelSource/scripts/gcc-x86_32-has-stack-protector.sh
    chmod u+w $kernelSource/scripts/gcc-x86_64-has-stack-protector.sh
    echo echo y > $kernelSource/scripts/gcc-x86_32-has-stack-protector.sh
    echo echo y > $kernelSource/scripts/gcc-x86_64-has-stack-protector.sh

    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$PWD/include"
  
    make KDIR=$kernelSource aufs.ko
  '';

  installPhase = ''
    ensureDir $out/bin
    cp util/aulchown $out/bin

    ensureDir $out/share/man/man5
    cp util/aufs.5 $out/share/man/man5

    ensureDir $out/lib/modules/$kernelVersion/misc
    cp aufs.ko $out/lib/modules/$kernelVersion/misc
  '';

  meta = {
    description = "Another Unionfs implementation for Linux - second generation";
    homepage = http://aufs.sourceforge.net/;
  };
}