From 4e39dcf27a332c307d6f38e16c62ef37cb770bb5 Mon Sep 17 00:00:00 2001 From: Summer Tea Date: Mon, 30 Dec 2024 11:52:31 -0500 Subject: [PATCH] pineflash: init at 0.5.5 --- .../pi/pineflash/fix_pkexec_path.patch | 22 ++++++ pkgs/by-name/pi/pineflash/package.nix | 70 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 pkgs/by-name/pi/pineflash/fix_pkexec_path.patch create mode 100644 pkgs/by-name/pi/pineflash/package.nix diff --git a/pkgs/by-name/pi/pineflash/fix_pkexec_path.patch b/pkgs/by-name/pi/pineflash/fix_pkexec_path.patch new file mode 100644 index 00000000000000..7d4648300de791 --- /dev/null +++ b/pkgs/by-name/pi/pineflash/fix_pkexec_path.patch @@ -0,0 +1,22 @@ +diff --git a/src/submodules/flash.rs b/src/submodules/flash.rs +index 5b224b2..e30f286 100644 +--- a/src/submodules/flash.rs ++++ b/src/submodules/flash.rs +@@ -107,7 +107,7 @@ impl Flasher { + let dfupath = "dfu-util"; + + #[cfg(target_os = "linux")] +- let command = Command::new("pkexec") ++ let command = Command::new("/run/wrappers/bin/pkexec") + // .env("PATH", path) + .arg(dfupath) + .arg("-D") +@@ -182,7 +182,7 @@ impl Flasher { + let blisppath = "blisp"; + + #[cfg(target_os = "linux")] +- let command = Command::new("pkexec") ++ let command = Command::new("/run/wrappers/bin/pkexec") + .env("PATH", "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:linux") + .arg(blisppath) + .arg("write") diff --git a/pkgs/by-name/pi/pineflash/package.nix b/pkgs/by-name/pi/pineflash/package.nix new file mode 100644 index 00000000000000..2e652396bb561d --- /dev/null +++ b/pkgs/by-name/pi/pineflash/package.nix @@ -0,0 +1,70 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rustPlatform, + pkg-config, + openssl, + systemd, + glib, + gtk3, + dfu-util, + blisp, + fontconfig, + libxkbcommon, + libGL, +}: +rustPlatform.buildRustPackage rec { + pname = "pineflash"; + version = "0.5.5"; + + src = fetchFromGitHub { + owner = "Spagett1"; + repo = "pineflash"; + tag = "${version}"; + hash = "sha256-4tcwEok36vuXbtlZNUkLNw1kHFQPBEJM/gWRhRWNLPg="; + }; + + cargoHash = "sha256-l01It6mUflENlADW6PpOQvK1o4qOjbTsMLB6n+OIl0U="; + + patches = [ + ./fix_pkexec_path.patch + ]; + + postPatch = '' + substituteInPlace src/submodules/flash.rs \ + --replace-fail 'let blisppath = "blisp";' 'let blisppath = "${blisp}/bin/blisp";' \ + --replace-fail 'let dfupath = "dfu-util";' 'let dfupath = "${dfu-util}/bin/dfu-util";' + ''; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + openssl + systemd + glib + gtk3 + fontconfig + libxkbcommon + libGL + dfu-util + blisp + ]; + + postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' + patchelf $out/bin/pineflash --add-rpath ${libxkbcommon}/lib + patchelf $out/bin/pineflash --add-rpath ${libGL}/lib + ''; + + meta = { + description = "GUI tool to flash IronOS to the Pinecil V1 and V2"; + homepage = "https://github.com/Spagett1/pineflash"; + license = lib.licenses.gpl2Only; + maintainers = with lib.maintainers; [ + acuteaangle + ]; + mainProgram = "pineflash"; + }; +}