Skip to content

Instantly share code, notes, and snippets.

@danbst
Created October 27, 2016 18:00
Show Gist options
  • Save danbst/7095be258fd8475b8a966dde4dc02ee2 to your computer and use it in GitHub Desktop.
Save danbst/7095be258fd8475b8a966dde4dc02ee2 to your computer and use it in GitHub Desktop.
{ pkgs }:
let
old_iproute = { fetchurl, stdenv, flex, bison, db4, iptables, pkgconfig }:
stdenv.mkDerivation rec {
name = "iproute2-3.6.0";
src = fetchurl {
url = http://kernel.org/pub/linux/utils/net/iproute2/iproute2-3.6.0.tar.xz;
sha256 = "0d05av2s7p552yszgj6glz6d74jlmg392s7n74hicgqfl16m85rd";
};
#patches = [ ./vpnc.patch ];
preConfigure =
''
patchShebangs ./configure
sed -e '/ARPDDIR/d' -i Makefile
'';
postConfigure = "cat Config";
makeFlags = "DESTDIR= LIBDIR=$(out)/lib SBINDIR=$(out)/sbin"
+ " CONFDIR=$(out)/etc DOCDIR=$(out)/share/doc/${name}"
+ " MANDIR=$(out)/share/man";
buildInputs = [ db4 iptables bison flex pkgconfig ];
#buildNativeInputs = [ bison ];
enableParallelBuilding = true;
# Get rid of useless TeX/SGML docs.
postInstall = "rm -rf $out/share/doc";
meta = {
homepage = http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2;
description = "A collection of utilities for controlling TCP/IP networking and traffic control in Linux";
platforms = stdenv.lib.platforms.linux;
maintainers = [ stdenv.lib.maintainers.eelco ];
};
};
debloat = { stdenv, fetchurl, lua, iproute, ethtool, kmod, coreutils }: stdenv.mkDerivation {
name = "debloat";
src = fetchurl {
url = "https://raw.githubusercontent.com/dtaht/deBloat/e472d44385eb0c5e2434321ec19536bb3392d084/src/debloat";
sha256 = "0ka3srjdb21w2ichmymm3m90lj90rm293n54d0mx72i6pwp12ljc";
};
propagatedBuildInputs = [ iproute ethtool ];
buildCommand = ''
cp $src debloat
substituteInPlace debloat \
--replace "/usr/bin/lua" "${lua}/bin/lua" \
--replace "\\|" "\\\\|" \
--replace "/sbin/lsmod" "${kmod}/bin/lsmod" \
--replace "/sbin/modprobe" "${kmod}/bin/modprobe" \
--replace "/sbin/tc" "${iproute}/bin/tc" \
--replace "/sbin/ethtool" "${ethtool}/bin/ethtool" \
--replace "/bin/cat" "${coreutils}/bin/cat" \
--replace "sch_efq_codel" "sch_fq_codel" \
--replace "sch_ns2_codel" "sch_fq_codel" \
--replace "sch_nfq_codel" "sch_fq_codel"
install -m555 -Dt $out/bin/ debloat
'';
};
in debloat {
inherit (pkgs) stdenv fetchurl ethtool kmod coreutils;
lua = pkgs.lua51Packages.lua;
iproute = old_iproute { inherit (pkgs) fetchurl stdenv flex bison db4 iptables pkgconfig; };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment