From 83e56a3a9015816afb54def60cd1ba926b3b5804 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 5 Mar 2023 22:32:56 +0000 Subject: [PATCH] add swconfig package --- pkgs/default.nix | 1 + pkgs/swconfig/default.nix | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 pkgs/swconfig/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 332bb75..cc5847b 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -37,4 +37,5 @@ # https://sourceforge.net/p/squashfs/mailman/message/26599379/ lzma = callPackage ./lzma {}; + swconfig = callPackage ./swconfig {}; } diff --git a/pkgs/swconfig/default.nix b/pkgs/swconfig/default.nix new file mode 100644 index 0000000..ac95205 --- /dev/null +++ b/pkgs/swconfig/default.nix @@ -0,0 +1,33 @@ +{ stdenv, buildPackages, libnl, ...} : +let switchDotH = buildPackages.fetchurl { + url = "https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob_plain;f=target/linux/generic/files/include/uapi/linux/switch.h;hb=99a188828713d6ff9c541590b08d4e63ef52f6d7"; + sha256 = "15kmhhcpd84y4f45rf8zai98c61jyvkc37p90pcxirna01x33wi8"; + name="switch.h"; +}; +in stdenv.mkDerivation { + src = buildPackages.fetchFromGitHub { + owner = "jekader"; + repo = "swconfig"; + rev = "66c760893ecdd1d603a7231fea9209daac57b610"; + sha256 = "0hi2rj1a1fbvr5n1090q1zzigjyxmn643jzrwngw4ij0g82za3al"; + }; + name = "swconfig"; + buildInputs = [ buildPackages.pkgconfig ]; + nativeBuildInputs = [ libnl ]; + CFLAGS="-O2 -Ifrom_kernel -I${libnl.dev}/include/libnl3"; + LDFLAGS="-L${libnl.out}/lib"; + + patchPhase = '' + mkdir -p from_kernel/linux + cp ${switchDotH} from_kernel/linux/switch.h + ''; + + buildPhase = '' + make swconfig + $STRIP swconfig + ''; + installPhase = '' + mkdir -p $out/bin + cp swconfig $out/bin + ''; +}