electron-chromedriver_33: 33.3.0 -> 33.3.1
[NixPkgs.git] / pkgs / applications / video / gyroflow / default.nix
blobfb237ac6fbbbbb87d0eba15ec07155985f010bbd
2   lib,
3   rustPlatform,
4   fetchFromGitHub,
5   makeDesktopItem,
6   clang,
7   copyDesktopItems,
8   patchelf,
9   pkg-config,
10   qt6,
11   alsa-lib,
12   bash,
13   ffmpeg,
14   mdk-sdk,
15   ocl-icd,
16   opencv,
18 let
19   lens-profiles = fetchFromGitHub {
20     owner = "gyroflow";
21     repo = "lens_profiles";
22     tag = "v19";
23     hash = "sha256-8R2mMqKxzoa5Sfqxs8pcfwUfo1PQKSrnM+60Ri3wiXY=";
24   };
26 rustPlatform.buildRustPackage rec {
27   pname = "gyroflow";
28   version = "1.6.0";
30   src = fetchFromGitHub {
31     owner = "gyroflow";
32     repo = "gyroflow";
33     tag = "v${version}";
34     hash = "sha256-Ib9GnHN23eTbd3nEwvZf3+CBSkUHycN77o3ura0Ze/0=";
35   };
37   useFetchCargoVendor = true;
39   cargoHash = "sha256-bqBFAobXwPC4V0OYHbwmkk7shfiFt3YMGAf7F5ybLAQ=";
41   nativeBuildInputs = [
42     clang
43     copyDesktopItems
44     patchelf
45     pkg-config
46     rustPlatform.bindgenHook
47     qt6.wrapQtAppsHook
48   ];
50   buildInputs = [
51     alsa-lib
52     bash
53     ffmpeg
54     mdk-sdk
55     ocl-icd
56     opencv
57     qt6.qtbase
58     qt6.qtdeclarative
59     qt6.qtsvg
60   ];
62   postPatch = ''
63     substituteInPlace build.rs \
64       --replace-fail 'println!("cargo:rustc-link-lib=static:+whole-archive=z")' ""
65   '';
67   # qml-video-rs and gyroflow assume that all Qt headers are installed
68   # in a single (qtbase) directory.  Apart form QtCore and QtGui from
69   # qtbase they need QtQuick and QtQml public and private headers from
70   # qtdeclarative:
71   # https://github.com/AdrianEddy/qml-video-rs/blob/bbf60090b966f0df2dd016e01da2ea78666ecea2/build.rs#L22-L40
72   # https://github.com/gyroflow/gyroflow/blob/v1.5.4/build.rs#L163-L186
73   # Additionally gyroflow needs QtQuickControls2:
74   # https://github.com/gyroflow/gyroflow/blob/v1.5.4/build.rs#L173
75   env.NIX_CFLAGS_COMPILE = toString [
76     "-I${qt6.qtdeclarative}/include/QtQuick"
77     "-I${qt6.qtdeclarative}/include/QtQuick/${qt6.qtdeclarative.version}"
78     "-I${qt6.qtdeclarative}/include/QtQuick/${qt6.qtdeclarative.version}/QtQuick"
79     "-I${qt6.qtdeclarative}/include/QtQml"
80     "-I${qt6.qtdeclarative}/include/QtQml/${qt6.qtdeclarative.version}"
81     "-I${qt6.qtdeclarative}/include/QtQml/${qt6.qtdeclarative.version}/QtQml"
82     "-I${qt6.qtdeclarative}/include/QtQuickControls2"
83   ];
85   # FFMPEG_DIR is used by ffmpeg-sys-next/build.rs and
86   # gyroflow/build.rs.  ffmpeg-sys-next fails to build if this dir
87   # does not contain ffmpeg *headers*.  gyroflow assumes that it
88   # contains ffmpeg *libraries*, but builds fine as long as it is set
89   # with any value.
90   env.FFMPEG_DIR = ffmpeg.dev;
92   # These variables are needed by gyroflow/build.rs.
93   # OPENCV_LINK_LIBS is based on the value in gyroflow/_scripts/common.just, with opencv_dnn added to fix linking.
94   env.OPENCV_LINK_PATHS = "${opencv}/lib";
95   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";
97   # For qml-video-rs. It concatenates "lib/" to this value so it needs a trailing "/":
98   env.MDK_SDK = "${mdk-sdk}/";
100   preCheck = ''
101     # qml-video-rs/build.rs wants to overwrite it:
102     find target -name libmdk.so.0 -exec chmod +w {} \;
103   '';
105   doCheck = false; # No tests.
107   postInstall = ''
108     mkdir -p $out/opt/Gyroflow
109     cp -r resources $out/opt/Gyroflow/
110     ln -s ${lens-profiles} $out/opt/Gyroflow/resources/camera_presets
112     rm -rf $out/lib
113     patchelf $out/bin/gyroflow --add-rpath ${mdk-sdk}/lib
115     mv $out/bin/gyroflow $out/opt/Gyroflow/
116     ln -s ../opt/Gyroflow/gyroflow $out/bin/
118     install -D ${./gyroflow-open.sh} $out/bin/gyroflow-open
119     install -Dm644 ${./gyroflow-mime.xml} $out/share/mime/packages/gyroflow.xml
120     install -Dm644 resources/icon.svg $out/share/icons/hicolor/scalable/apps/gyroflow.svg
121   '';
123   desktopItems = [
124     (makeDesktopItem ({
125       name = "gyroflow";
126       desktopName = "Gyroflow";
127       genericName = "Video stabilization using gyroscope data";
128       comment = meta.description;
129       icon = "gyroflow";
130       exec = "gyroflow-open %u";
131       terminal = false;
132       mimeTypes = [ "application/x-gyroflow" ];
133       categories = [
134         "AudioVideo"
135         "Video"
136         "AudioVideoEditing"
137         "Qt"
138       ];
139       startupNotify = true;
140       startupWMClass = "gyroflow";
141       prefersNonDefaultGPU = true;
142     }))
143   ];
145   meta = {
146     description = "Advanced gyro-based video stabilization tool";
147     homepage = "https://gyroflow.xyz";
148     license = with lib.licenses; [
149       gpl3Plus
150       cc0
151     ];
152     maintainers = with lib.maintainers; [ orivej ];
153     platforms = [ "x86_64-linux" ];
154   };