Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
229 lines (208 loc) · 6.92 KB
/
Copy pathflake.nix
File metadata and controls
229 lines (208 loc) · 6.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
{
description = "NectarLink - Android and Linux PC working as one";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
packageBuilder = system:
let
pkgs = nixpkgs.legacyPackages.${system};
qtEnv = pkgs.qt6.env "qt6-env" [
pkgs.qt6.qtbase
pkgs.qt6.qtdeclarative
pkgs.qt6.qtsvg
pkgs.qt6.qtwayland
pkgs.qt6.qtshadertools
pkgs.qt6.qttools
];
in pkgs.rustPlatform.buildRustPackage {
pname = "nectarlink";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = with pkgs; [
pkg-config
cmake
ninja
qt6.wrapQtAppsHook
];
dontUseCmakeConfigure = true;
dontUseNinjaBuild = true;
dontUseNinjaInstall = true;
buildInputs = with pkgs; [
qtEnv
pkgs.qt6.qtbase
pkgs.qt6.qtdeclarative
pkgs.qt6.qtsvg
pkgs.qt6.qtwayland
pkgs.libGL
pkgs.vulkan-loader
pkgs.libx11
pkgs.libxkbcommon
pkgs.ffmpeg_8
];
LRELEASE = "${qtEnv}/bin/lrelease";
QT_PLUGIN_PATH = "${qtEnv}/lib/qt-6/plugins";
QML2_IMPORT_PATH = "${qtEnv}/lib/qt-6/qml";
preBuild = ''
mkdir -p $TMPDIR/qt-wrap
cat > $TMPDIR/qt-wrap/qt.conf <<EOF
[Paths]
Prefix = ${qtEnv}
Headers = include
Libraries = lib
Plugins = lib/qt-6/plugins
QmlImports = lib/qt-6/qml
EOF
ln -s ${qtEnv}/bin/qmake $TMPDIR/qt-wrap/qmake
export QMAKE="$TMPDIR/qt-wrap/qmake"
export PATH="$TMPDIR/qt-wrap:$PATH"
'';
cargoBuildFlags = [
"-p" "nectarlink-desktop"
"-p" "nectarlink-cli"
];
doCheck = false;
# These libraries are dlopen()ed, not linked, so fixup's
# patchelf --shrink-rpath drops them as unused if they are added
# earlier. Add them after fixup, on the real binary behind the Qt
# wrapper. ffmpeg_8 here and in buildInputs: h264.rs knows
# libavcodec 59-62, linux_video_codec.cpp dlopen()s the major of
# the headers it was built with, and nixpkgs' default ffmpeg is 9
# (libavcodec 63).
postFixup = ''
patchelf --add-rpath "${pkgs.lib.makeLibraryPath (with pkgs; [
libGL
vulkan-loader
libx11
libxkbcommon
libxtst
ffmpeg_8
openh264
lame
])}" $out/bin/.nectarlink-desktop-wrapped
'';
postInstall = ''
# Translations
mkdir -p $out/share/nectarlink
for qm in target/*/*/nectarlink_*.qm target/*/nectarlink_*.qm; do
if [ -f "$qm" ]; then
cp -n "$qm" $out/share/nectarlink/ || true
fi
done
# Desktop integration
install -Dm644 desktop/packaging/linux/nectarlink.desktop $out/share/applications/nectarlink.desktop
install -Dm644 desktop/packaging/linux/org.nectarlink.desktop.metainfo.xml $out/share/metainfo/org.nectarlink.desktop.metainfo.xml
# Icons
if [ -f assets/brand/icon.svg ]; then
install -Dm644 assets/brand/icon.svg $out/share/icons/hicolor/scalable/apps/nectarlink.svg
install -Dm644 assets/brand/icon.svg $out/share/pixmaps/nectarlink.svg
fi
if [ -f assets/brand/icon-512.png ]; then
install -Dm644 assets/brand/icon-512.png $out/share/icons/hicolor/512x512/apps/nectarlink.png
install -Dm644 assets/brand/icon-512.png $out/share/pixmaps/nectarlink.png
fi
'';
meta = with pkgs.lib; {
description = "Your Android phone and your PC, working as one";
homepage = "https://github.com/thtbee/nectarlink";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ ];
platforms = platforms.linux;
mainProgram = "nectarlink-desktop";
};
};
in
(flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = nixpkgs.legacyPackages.${system};
qtEnv = pkgs.qt6.env "qt6-env" [
pkgs.qt6.qtbase
pkgs.qt6.qtdeclarative
pkgs.qt6.qtsvg
pkgs.qt6.qtwayland
pkgs.qt6.qtshadertools
pkgs.qt6.qttools
];
in {
packages.default = packageBuilder system;
packages.nectarlink = packageBuilder system;
apps.default = {
type = "app";
program = "${self.packages.${system}.default}/bin/nectarlink-desktop";
meta.description = "NectarLink desktop application";
};
apps.cli = {
type = "app";
program = "${self.packages.${system}.default}/bin/nectarlink";
meta.description = "NectarLink command-line client";
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
pkg-config
cmake
ninja
rustc
cargo
rustfmt
clippy
rust-analyzer
patchelf
];
buildInputs = with pkgs; [
qtEnv
qt6.qtbase
qt6.qtdeclarative
qt6.qtsvg
qt6.qtwayland
libGL
vulkan-loader
libx11
libxkbcommon
ffmpeg_8
];
shellHook = ''
export QT_WRAP_DIR=$(mktemp -d)
cat > "$QT_WRAP_DIR/qt.conf" <<EOF
[Paths]
Prefix = ${qtEnv}
Headers = include
Libraries = lib
Plugins = lib/qt-6/plugins
QmlImports = lib/qt-6/qml
EOF
ln -s "${qtEnv}/bin/qmake" "$QT_WRAP_DIR/qmake"
export QMAKE="$QT_WRAP_DIR/qmake"
export PATH="$QT_WRAP_DIR:$PATH"
'';
LRELEASE = "${qtEnv}/bin/lrelease";
QT_PLUGIN_PATH = "${qtEnv}/lib/qt-6/plugins";
QML2_IMPORT_PATH = "${qtEnv}/lib/qt-6/qml";
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (with pkgs; [
qtEnv
libGL
vulkan-loader
libx11
libxkbcommon
ffmpeg_8
])}:$LD_LIBRARY_PATH";
LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (with pkgs; [
qtEnv
libGL
vulkan-loader
libx11
libxkbcommon
ffmpeg_8
])}:$LIBRARY_PATH";
};
})
) // {
overlays.default = final: prev: {
nectarlink = packageBuilder final.system;
};
};
}