summary refs log tree commit diff
path: root/pkgs/os-specific/linux/fanctl/default.nix
blob: f60951f5541eb227381a6f3219f261de6e410b59 (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
{ stdenv, lib, fetchurl, gnugrep, glibc, gawk, coreutils, bridge-utils, iproute
, dnsmasq, iptables, kmod, utillinux, gnused }:

stdenv.mkDerivation rec {
  name = "fanctl-${version}";

  version = "0.9.0";

  src = fetchurl {
    url = "https://launchpad.net/ubuntu/+archive/primary/+files/ubuntu-fan_${version}.tar.xz";
    sha256 = "03dv5zzb8fkl9kkbhznxm48d6j3fjms74fn0s1zip2gz53l1s14n";
  };

  # The Ubuntu package creates a number of state/config directories upon
  # installation, and so the fanctl script expects those directories to exist
  # before being used. Instead, we patch the fanctl script to gracefully handle
  # the fact that the directories might not exist yet.
  # Also, when dnsmasq is given --conf-file="", it will still attempt to read
  # /etc/dnsmasq.conf; if that file does not exist, dnsmasq subsequently fails,
  # so we'll use /dev/null, which actually works as intended.
  patches = [ ./robustness.patch ];

  postPatch = ''
    substituteInPlace fanctl \
      --replace '@PATH@' \
                '${lib.makeBinPath [
                     gnugrep gawk coreutils bridge-utils iproute dnsmasq
                     iptables kmod utillinux gnused
                     glibc # needed for getent
                   ]}'
  '';

  installPhase = ''
    mkdir -p $out/bin $out/man/man8
    cp fanctl.8 $out/man/man8
    cp fanctl $out/bin
  '';

  meta = with lib; {
    description = "Ubuntu FAN network support enablement";
    homepage = "https://launchpad.net/ubuntu/+source/ubuntu-fan";
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ cstrahan ];
  };
}