Skip to content

Instantly share code, notes, and snippets.

@HelloWorld017
Last active July 30, 2026 10:57
Show Gist options
  • Select an option

  • Save HelloWorld017/0f0f5ef794656ba401e50e9cf393d750 to your computer and use it in GitHub Desktop.

Select an option

Save HelloWorld017/0f0f5ef794656ba401e50e9cf393d750 to your computer and use it in GitHub Desktop.
SPFlashTools Flake

SPFlashTools devShells Flake

It's might better to do wrapQtAppsHook.
Maybe I'll do it next time when I need it.

Usage

Save this and $ nix develop. Go to directory where it contains SPFlashToolV6 and run $ spflashtool. You must expose your /dev/ttyACM0 as 0666. Use following:

  services.udev.extraRules = ''
    # Rule for mediatek
    KERNEL=="ttyACM*", ATTRS{idVendor}=="0e8d", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
  '';
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1770841267,
"narHash": "sha256-9xejG0KoqsoKEGp2kVbXRlEYtFFcDTHjidiuX8hGO44=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
targetPkgs = pkgs: (with pkgs; [
# System Utils
dbus
glib
glibc
stdenv.cc.cc.lib
libkrb5
libGL
libxkbcommon
wayland
zlib
# Qt Libraries
qt5.qtbase
qt5.qtserialport
qt5.qtwayland
qt5.qtxmlpatterns
libsForQt5.qt5.qtwayland
]);
spFlashToolScript = pkgs.writeShellScriptBin "spflashtool" ''
export LD_LIBRARY_PATH="$FHS_BUILDENV_ROOT/lib:$LD_LIBRARY_PATH"
export QT_PLUGIN_PATH="${pkgs.qt5.qtbase}/${pkgs.qt5.qtbase.qtPluginPrefix}:${pkgs.qt5.qtwayland}/${pkgs.qt5.qtbase.qtPluginPrefix}"
export QT_QPA_PLATFORM=wayland
exec ./SPFlashToolV6 "$@"
'';
spFlashToolEnv = pkgs.buildFHSEnv {
name = "sp-flash-tool-env";
targetPkgs = pkgs: (targetPkgs pkgs) ++ [spFlashToolScript];
runScript = "zsh";
};
in {
devShells.${system} = {
default = spFlashToolEnv.env;
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment