summary refs log tree commit diff
path: root/pkgs/os-specific/linux/crda/default.nix
blob: c337da2fe723e492649999b4476e914ba31a7171 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{ lib, stdenv, fetchurl, fetchpatch, libgcrypt, libnl, pkg-config, python3Packages, wireless-regdb }:

stdenv.mkDerivation rec {
  pname = "crda";
  version = "3.18";

  src = fetchurl {
    sha256 = "1gydiqgb08d9gbx4l6gv98zg3pljc984m50hmn3ysxcbkxkvkz23";
    url = "http://kernel.org/pub/software/network/crda/crda-${version}.tar.xz";
  };

  patches = [
    # Switch to Python 3
    # https://lore.kernel.org/linux-wireless/1437542484-23409-1-git-send-email-ahmed.taahir@gmail.com/
    (fetchpatch {
      url = "https://lore.kernel.org/linux-wireless/1437542484-23409-2-git-send-email-ahmed.taahir@gmail.com/raw";
      sha256 = "0s2n340cgaasvg1k8g9v8xjrbh4y2mcgrhdmv97ja2fs8xjcjbf1";
    })
    (fetchpatch {
      url = "https://lore.kernel.org/linux-wireless/1437542484-23409-3-git-send-email-ahmed.taahir@gmail.com/raw";
      sha256 = "01dlfw7kqhyx025jxq2l75950b181p9r7i9zkflcwvbzzdmx59md";
    })
  ];

  buildInputs = [ libgcrypt libnl ];
  nativeBuildInputs = [
    pkg-config
    python3Packages.pycrypto
  ];

  postPatch = ''
    patchShebangs utils/
    substituteInPlace Makefile \
      --replace ldconfig true \
      --replace pkg-config $PKG_CONFIG
    sed -i crda.c \
      -e "/\/usr\/.*\/regulatory.bin/d" \
      -e "s|/lib/crda|${wireless-regdb}/lib/crda|g"
  '';

  makeFlags = [
    "PREFIX=$(out)"
    "SBINDIR=$(out)/bin/"
    "UDEV_RULE_DIR=$(out)/lib/udev/rules.d/"
    "REG_BIN=${wireless-regdb}/lib/crda/regulatory.bin"
  ];

  NIX_CFLAGS_COMPILE = "-Wno-error=unused-const-variable";

  buildFlags = [ "all_noverify" ];
  enableParallelBuilding = true;

  doCheck = true;
  checkTarget = "verify";

  postInstall = ''
    # The patch installs build header
    rm $out/include/reglib/keys-gcrypt.h
  '';

  meta = with lib; {
    description = "Linux wireless Central Regulatory Domain Agent";
    longDescription = ''
      CRDA acts as the udev helper for communication between the kernel and
      userspace for regulatory compliance. It relies on nl80211 for communication.

      CRDA is intended to be run only through udev communication from the kernel.
      To use it under NixOS, add

        services.udev.packages = [ pkgs.crda ];

      to the system configuration.
    '';
    homepage = "http://drvbp1.linux-foundation.org/~mcgrof/rel-html/crda/";
    license = licenses.free; # "copyleft-next 0.3.0", as yet without a web site
    platforms = platforms.linux;
  };
}