nixpkgs/pkgs/tools/misc/qflipper/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

106 lines
2.1 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, pkg-config
, zlib
, libusb1
, libGL
, qmake
, wrapGAppsHook3
, wrapQtAppsHook
, mkDerivation
, qttools
, qtbase
, qt3d
, qtsvg
, qtserialport
, qtdeclarative
, qtquickcontrols
, qtquickcontrols2
, qtgraphicaleffects
, qtwayland
, nix-update-script
}:
let
pname = "qFlipper";
version = "1.3.3";
hash = "sha256-/Xzy+OA0Nl/UlSkOOZW2YsOHdJvS/7X3Z3ITkPByAOc=";
timestamp = "99999999999";
commit = "nix-${version}";
in
mkDerivation {
inherit pname version;
src = fetchFromGitHub {
owner = "flipperdevices";
repo = "qFlipper";
rev = version;
fetchSubmodules = true;
inherit hash;
};
nativeBuildInputs = [
pkg-config
qmake
qttools
wrapGAppsHook3
wrapQtAppsHook
];
buildInputs = [
zlib
libusb1
libGL
qtbase
qt3d
qtsvg
qtserialport
qtdeclarative
qtquickcontrols
qtquickcontrols2
qtgraphicaleffects
] ++ lib.optionals (stdenv.hostPlatform.isLinux) [
qtwayland
];
qmakeFlags = [
"DEFINES+=DISABLE_APPLICATION_UPDATES"
"CONFIG+=qtquickcompiler"
];
dontWrapGApps = true;
postPatch = ''
substituteInPlace qflipper_common.pri \
--replace 'GIT_VERSION = unknown' 'GIT_VERSION = "${version}"' \
--replace 'GIT_TIMESTAMP = 0' 'GIT_TIMESTAMP = ${timestamp}' \
--replace 'GIT_COMMIT = unknown' 'GIT_COMMIT = "${commit}"'
cat qflipper_common.pri
'';
postInstall = ''
mkdir -p $out/bin
${lib.optionalString stdenv.hostPlatform.isDarwin ''
cp qFlipper.app/Contents/MacOS/qFlipper $out/bin
''}
cp qFlipper-cli $out/bin
mkdir -p $out/etc/udev/rules.d
cp installer-assets/udev/42-flipperzero.rules $out/etc/udev/rules.d/
'';
passthru.updateScript = nix-update-script { };
meta = with lib; {
broken = stdenv.hostPlatform.isDarwin;
description = "Cross-platform desktop tool to manage your flipper device";
homepage = "https://flipperzero.one/";
license = licenses.gpl3Only;
maintainers = with maintainers; [ cab404 ];
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ]; # qtbase doesn't build yet on aarch64-darwin
};
}