{ lib, pkgs, ... }:
let
  uconsole4gRuntime = with pkgs; [
    bash
    coreutils
    gnugrep
    gnused
    gawk
    util-linux
    usbutils
    pciutils
    lsb-release
    libgpiod
    modemmanager
    iproute2
    iputils
    busybox
    socat
    systemd
  ];

  # Use a lightweight wrapper to avoid ShellCheck gating the build.
  uconsole4gCm5 = pkgs.writeShellScriptBin "uconsole-4g-cm5" ''
    export PATH=${lib.makeBinPath uconsole4gRuntime}:$PATH
    exec ${pkgs.bash}/bin/bash ${./uconsole-4g-cm5.sh} "$@"
  '';
in
{
  networking.modemmanager.enable = true;

  environment.systemPackages = with pkgs; [
    libgpiod
    uconsole4gCm5
    socat
    ripgrep
  ];
}
