From 9cb73f3fec6ee96891f4e9c6ad4dcb599f485ffa Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 14 May 2024 12:56:58 +0100 Subject: [PATCH] barebones usb_modeswitch package --- overlay.nix | 2 ++ pkgs/default.nix | 1 + pkgs/usb-modeswitch/default.nix | 39 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 pkgs/usb-modeswitch/default.nix diff --git a/overlay.nix b/overlay.nix index d90f6ea..454fe84 100644 --- a/overlay.nix +++ b/overlay.nix @@ -271,6 +271,8 @@ extraPkgs // { ''; }; + libusb1 = prev.libusb1.override { enableUdev = false; }; + util-linux-small = prev.util-linux.override { ncursesSupport = false; pamSupport = false; diff --git a/pkgs/default.nix b/pkgs/default.nix index 946df60..b63ab3a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -110,6 +110,7 @@ in { systemconfig = callPackage ./systemconfig {}; tufted = callPackage ./tufted {}; uevent-watch = callPackage ./uevent-watch {}; + usb-modeswitch = callPackage ./usb-modeswitch {}; writeAshScript = callPackage ./write-ash-script {}; writeFennel = callPackage ./write-fennel {}; writeFennelScript = callPackage ./write-fennel-script {}; diff --git a/pkgs/usb-modeswitch/default.nix b/pkgs/usb-modeswitch/default.nix new file mode 100644 index 0000000..7b5c021 --- /dev/null +++ b/pkgs/usb-modeswitch/default.nix @@ -0,0 +1,39 @@ +# usb modeswitch without udev, tcl, coreutils, bash dependencies +{ stdenv +, lib +, fetchurl +, pkg-config +, libusb1 +}: +let + pname = "usb-modeswitch"; + version = "2.6.0"; +in stdenv.mkDerivation { + inherit pname version; + + src = fetchurl { + url = "http://www.draisberghof.de/usb_modeswitch/${pname}-${version}.tar.bz2"; + sha256 = "18wbbxc5cfsmikba0msdvd5qlaga27b32nhrzicyd9mdddp265f2"; + }; + + preBuild = '' + makeFlagsArray+=(LIBS="$($PKG_CONFIG --libs --cflags libusb-1.0)") + ''; + makeFlags = [ + "PREFIX=$(out)" + "usb_modeswitch" + ]; + + buildInputs = [ libusb1 ]; + nativeBuildInputs = [ pkg-config ]; + + installPhase = '' + mkdir -p $out/bin + cp usb_modeswitch $out/bin + ''; + + meta = { + license = lib.licenses.gpl2; + maintainers = []; + }; +}