biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / applications / video / gyroflow / default.nix
blob5d3673c2b23d874fa38892d3eefe96e3261a3210
1 { lib, rustPlatform, fetchFromGitHub, callPackage, makeDesktopItem
2 , clang, copyDesktopItems, patchelf, pkg-config, wrapQtAppsHook
3 , alsa-lib, bash, ffmpeg, mdk-sdk, ocl-icd, opencv, qtbase, qtdeclarative, qtsvg
4 }:
6 rustPlatform.buildRustPackage rec {
7   pname = "gyroflow";
8   version = "1.5.4-2024-09-05";
10   src = fetchFromGitHub {
11     owner = "gyroflow";
12     repo = "gyroflow";
13     rev = "52038dedad0bd14d6af68db36a09da0243ad5455";
14     hash = "sha256-EuhUF2b8YWv2eN2pcoHA0SlnyeQ8gJ5eHbXi6G4GIzk=";
15   };
17   cargoLock = {
18     lockFile = ./Cargo.lock;
19     outputHashes = {
20       "ahrs-0.6.0" = "sha256-CxWyX8t+BjqIyNj1p1LdkCmNrtJkudmKgZPv0MVcghY=";
21       "akaze-0.7.0" = "sha256-KkGXKoVRZZ7HUTtWYBerrN36a7RqsHjYQb+bwG1JagY=";
22       "app_dirs2-2.5.5" = "sha256-nQ5Cs9r1k/3zjqXJ18Oilk8ErLKim7bGwCXDlQW4GRQ=";
23       "fc-blackbox-0.2.0" = "sha256-82DuI0KuHhDVhCMUsnDqk6Fk774VpvoJ1qYFLO+n1X4=";
24       "ffmpeg-next-7.0.4" = "sha256-F1N70tSxdC36uS9Bh7X2S9Wspd7bcCbGPmoMRs1cm8Y=";
25       "ffmpeg-sys-next-7.0.2" = "sha256-7C46WJseKIhqXW0cQGaF8Q/xQi7sX+e8fKVrhBMVwZE=";
26       "keep-awake-0.1.0" = "sha256-iZuntDkAhDZBojRgNEupAExtqOhiw4mf6XK0N6ff2Oc=";
27       "mp4parse-0.17.0" = "sha256-DktX6zmQsHBlo7uLgLXcXWxKq9uisnX0R16lftWRLZY=";
28       "naga-22.0.0" = "sha256-+ngomv0VyWKNDkSGVI/f5wtDyLs79qiXxtj3qNOsbFc=";
29       "nshare-0.9.0" = "sha256-PAV41mMLDmhkAz4+qyf+MZnYTAdMwjk83+f+RdaJji8=";
30       "qmetaobject-0.2.10" = "sha256-kEwFjDe1tYTLQ8XdjrPyYEYnjVFyYeaWUPCj5D8mg7A=";
31       "qml-video-rs-0.1.0" = "sha256-8RYB+numVy7u29EYtSSdf/+cTsUMVjrcw4u5mqB7KbE=";
32       "rs-sync-0.1.0" = "sha256-6xQb0CUlBDx7S7zsqNL9zfZZtkmw0cbUUXd6pOYIrXI=";
33       "spirv-std-0.9.0" = "sha256-uZn1p2pM5UYQKlY9u16aafPH7dfQcSG7PaFDd1sT4Qc=";
34       "system_shutdown-4.0.1" = "sha256-YypNnZzTxkmUgIxaP4jOpFBje/fEzI5L1g+3pJgMd0w=";
35       "telemetry-parser-0.3.0" = "sha256-U26cWC7pSw4NFiu43BZf+KlLy9NU61iRpFx3Btse1aY=";
36      };
37   };
39   lens-profiles = callPackage ./lens-profiles.nix { };
41   nativeBuildInputs = [
42     clang copyDesktopItems patchelf pkg-config rustPlatform.bindgenHook wrapQtAppsHook
43   ];
45   buildInputs = [ alsa-lib bash ffmpeg mdk-sdk ocl-icd opencv qtbase qtdeclarative qtsvg ];
47   patches = [ ./no-static-zlib.patch ];
49   # qml-video-rs and gyroflow assume that all Qt headers are installed
50   # in a single (qtbase) directory.  Apart form QtCore and QtGui from
51   # qtbase they need QtQuick and QtQml public and private headers from
52   # qtdeclarative:
53   # https://github.com/AdrianEddy/qml-video-rs/blob/bbf60090b966f0df2dd016e01da2ea78666ecea2/build.rs#L22-L40
54   # https://github.com/gyroflow/gyroflow/blob/v1.5.4/build.rs#L163-L186
55   # Additionally gyroflow needs QtQuickControls2:
56   # https://github.com/gyroflow/gyroflow/blob/v1.5.4/build.rs#L173
57   env.NIX_CFLAGS_COMPILE = toString [
58     "-I${qtdeclarative}/include/QtQuick"
59     "-I${qtdeclarative}/include/QtQuick/${qtdeclarative.version}"
60     "-I${qtdeclarative}/include/QtQuick/${qtdeclarative.version}/QtQuick"
61     "-I${qtdeclarative}/include/QtQml"
62     "-I${qtdeclarative}/include/QtQml/${qtdeclarative.version}"
63     "-I${qtdeclarative}/include/QtQml/${qtdeclarative.version}/QtQml"
64     "-I${qtdeclarative}/include/QtQuickControls2"
65   ];
67   # FFMPEG_DIR is used by ffmpeg-sys-next/build.rs and
68   # gyroflow/build.rs.  ffmpeg-sys-next fails to build if this dir
69   # does not contain ffmpeg *headers*.  gyroflow assumes that it
70   # contains ffmpeg *libraries*, but builds fine as long as it is set
71   # with any value.
72   env.FFMPEG_DIR = ffmpeg.dev;
74   # These variables are needed by gyroflow/build.rs.
75   # OPENCV_LINK_LIBS is based on the value in gyroflow/_scripts/common.just, with opencv_dnn added to fix linking.
76   env.OPENCV_LINK_PATHS = "${opencv}/lib";
77   env.OPENCV_LINK_LIBS = "opencv_core,opencv_calib3d,opencv_dnn,opencv_features2d,opencv_imgproc,opencv_video,opencv_flann,opencv_imgcodecs,opencv_objdetect,opencv_stitching,png";
79   # For qml-video-rs. It concatenates "lib/" to this value so it needs a trailing "/":
80   env.MDK_SDK = "${mdk-sdk}/";
82   preCheck = ''
83     # qml-video-rs/build.rs wants to overwrite it:
84     find target -name libmdk.so.0 -exec chmod +w {} \;
85   '';
87   doCheck = false; # No tests.
89   postInstall = ''
90     mkdir -p $out/opt/Gyroflow
91     cp -r resources $out/opt/Gyroflow/
92     ln -s ${lens-profiles} $out/opt/Gyroflow/resources/camera_presets
94     rm -rf $out/lib
95     patchelf $out/bin/gyroflow --add-rpath ${mdk-sdk}/lib
97     mv $out/bin/gyroflow $out/opt/Gyroflow/
98     ln -s ../opt/Gyroflow/gyroflow $out/bin/
100     install -D ${./gyroflow-open.sh} $out/bin/gyroflow-open
101     install -Dm644 ${./gyroflow-mime.xml} $out/share/mime/packages/gyroflow.xml
102     install -Dm644 resources/icon.svg $out/share/icons/hicolor/scalable/apps/gyroflow.svg
103   '';
105   desktopItems = [
106     (makeDesktopItem (rec {
107       name = "gyroflow";
108       desktopName = "Gyroflow";
109       genericName = "Video stabilization using gyroscope data";
110       comment = meta.description;
111       icon = "gyroflow";
112       exec = "gyroflow-open %u";
113       terminal = false;
114       mimeTypes = [ "application/x-gyroflow" ];
115       categories = [ "AudioVideo" "Video" "AudioVideoEditing" "Qt" ];
116       startupNotify = true;
117       startupWMClass = "gyroflow";
118       prefersNonDefaultGPU = true;
119     }))
120   ];
122   meta = with lib; {
123     description = "Advanced gyro-based video stabilization tool";
124     homepage = "https://gyroflow.xyz/";
125     license = licenses.gpl3Plus;
126     maintainers = with maintainers; [ orivej ];
127     platforms = [ "x86_64-linux" ];
128   };