19 lens-profiles = fetchFromGitHub {
21 repo = "lens_profiles";
23 hash = "sha256-8R2mMqKxzoa5Sfqxs8pcfwUfo1PQKSrnM+60Ri3wiXY=";
26 rustPlatform.buildRustPackage rec {
30 src = fetchFromGitHub {
34 hash = "sha256-Ib9GnHN23eTbd3nEwvZf3+CBSkUHycN77o3ura0Ze/0=";
37 useFetchCargoVendor = true;
39 cargoHash = "sha256-bqBFAobXwPC4V0OYHbwmkk7shfiFt3YMGAf7F5ybLAQ=";
46 rustPlatform.bindgenHook
63 substituteInPlace build.rs \
64 --replace-fail 'println!("cargo:rustc-link-lib=static:+whole-archive=z")' ""
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
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"
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
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}/";
101 # qml-video-rs/build.rs wants to overwrite it:
102 find target -name libmdk.so.0 -exec chmod +w {} \;
105 doCheck = false; # No tests.
108 mkdir -p $out/opt/Gyroflow
109 cp -r resources $out/opt/Gyroflow/
110 ln -s ${lens-profiles} $out/opt/Gyroflow/resources/camera_presets
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
126 desktopName = "Gyroflow";
127 genericName = "Video stabilization using gyroscope data";
128 comment = meta.description;
130 exec = "gyroflow-open %u";
132 mimeTypes = [ "application/x-gyroflow" ];
139 startupNotify = true;
140 startupWMClass = "gyroflow";
141 prefersNonDefaultGPU = true;
146 description = "Advanced gyro-based video stabilization tool";
147 homepage = "https://gyroflow.xyz";
148 license = with lib.licenses; [
152 maintainers = with lib.maintainers; [ orivej ];
153 platforms = [ "x86_64-linux" ];