Skip to content

Commit add5fe3

Browse files
committed
fixes missing dependencies for defguard-client and defguard-service
* Adds `iproute2` to the wrapped `defguard-service` * Adds `update-desktop-database` to the wrapped `defguard-client` * Tauri Builds on the GTK3/WebKitGTK4.1, there was a mismatch with GTK4/WebKitGTK4.1, (GTK4 should use WebKitGTK6.0, but that isn't supported [yet](tauri-apps/tauri#14684) for tauri. * No `Makefile` so we can overwrite/rename `postInstall` with `installPhase`. * Formatting With these changes in place, it fixes issue [DefGuard#728](DefGuard#728).
1 parent a4fc65f commit add5fe3

File tree

2 files changed

+96
-67
lines changed

2 files changed

+96
-67
lines changed

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/package.nix

Lines changed: 90 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
rustc,
77
cargo,
88
makeDesktopItem,
9-
}: let
9+
}:
10+
let
1011
pname = "defguard-client";
1112
version = "1.6.2"; # TODO: Get this from Cargo.toml or git
1213

@@ -16,7 +17,10 @@
1617
icon = pname;
1718
desktopName = "Defguard";
1819
genericName = "Defguard VPN Client";
19-
categories = ["Network" "Security"];
20+
categories = [
21+
"Network"
22+
"Security"
23+
];
2024
};
2125

2226
pnpm = pkgs.pnpm_10;
@@ -29,7 +33,7 @@
2933
gdk-pixbuf
3034
glib
3135
glib-networking
32-
gtk4
36+
gtk3
3337
harfbuzz
3438
librsvg
3539
libsoup_3
@@ -38,6 +42,7 @@
3842
openssl
3943
libayatana-appindicator
4044
desktop-file-utils
45+
iproute2
4146
];
4247

4348
nativeBuildInputs = [
@@ -55,63 +60,87 @@
5560
rustPlatform.cargoSetupHook
5661
# helper to add dynamic library paths
5762
pkgs.makeWrapper
63+
pkgs.wrapGAppsHook3
5864
];
5965
in
60-
stdenv.mkDerivation (finalAttrs: rec {
61-
inherit pname version buildInputs nativeBuildInputs;
62-
63-
src = ../.;
64-
65-
# prefetch cargo dependencies
66-
cargoRoot = "src-tauri";
67-
buildAndTestSubdir = "src-tauri";
68-
69-
cargoDeps = rustPlatform.importCargoLock {
70-
lockFile = ../src-tauri/Cargo.lock;
71-
};
72-
73-
# prefetch pnpm dependencies
74-
pnpmDeps = pkgs.pnpm.fetchDeps {
75-
inherit
76-
(finalAttrs)
77-
pname
78-
version
79-
src
80-
;
81-
82-
fetcherVersion = 2;
83-
hash = "sha256-v47yaNnt7vLDPR7WVLSonmZBBOkYWnmTUqMiPZ/WCGo=";
84-
};
85-
86-
buildPhase = ''
87-
pnpm tauri build
88-
'';
89-
90-
postInstall = ''
91-
mkdir -p $out/bin
92-
93-
# copy client binary
94-
cp src-tauri/target/release/${pname} $out/bin/
95-
96-
# copy background service binary
97-
cp src-tauri/target/release/defguard-service $out/bin/
98-
99-
# copy CLI binary
100-
cp src-tauri/target/release/dg $out/bin/
101-
102-
# add required library to client binary RPATH
103-
wrapProgram $out/bin/${pname} \
104-
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [pkgs.libayatana-appindicator pkgs.desktop-file-utils]}
105-
106-
mkdir -p $out/share/applications
107-
cp ${desktopItem}/share/applications/* $out/share/applications/
108-
'';
109-
110-
meta = with lib; {
111-
description = "Defguard VPN Client";
112-
homepage = "https://defguard.net";
113-
# license = licenses.gpl3Only;
114-
maintainers = with maintainers; [];
115-
platforms = platforms.linux;
116-
};
117-
})
66+
stdenv.mkDerivation (finalAttrs: rec {
67+
inherit
68+
pname
69+
version
70+
buildInputs
71+
nativeBuildInputs
72+
;
73+
74+
src = ../.;
75+
76+
# prefetch cargo dependencies
77+
cargoRoot = "src-tauri";
78+
buildAndTestSubdir = "src-tauri";
79+
80+
cargoDeps = rustPlatform.importCargoLock {
81+
lockFile = ../src-tauri/Cargo.lock;
82+
};
83+
84+
# prefetch pnpm dependencies
85+
pnpmDeps = pnpm.fetchDeps {
86+
inherit (finalAttrs)
87+
pname
88+
version
89+
src
90+
;
91+
92+
fetcherVersion = 2;
93+
hash = "sha256-Xtn0FIq097sLEl/iodLeVVOYxVLx1ePJ8UjJUmgB2f0=";
94+
};
95+
96+
buildPhase = ''
97+
pnpm tauri build
98+
'';
99+
100+
installPhase = ''
101+
mkdir -p $out/bin
102+
103+
# copy client binary
104+
cp src-tauri/target/release/${pname} $out/bin/
105+
106+
# copy background service binary
107+
cp src-tauri/target/release/defguard-service $out/bin/
108+
109+
# copy CLI binary
110+
cp src-tauri/target/release/dg $out/bin/
111+
112+
# copy Tauri resources (icons for system tray, etc.)
113+
mkdir -p $out/lib/${pname}
114+
cp -r src-tauri/resources/* $out/lib/${pname}/
115+
116+
mkdir -p $out/share/applications
117+
cp ${desktopItem}/share/applications/* $out/share/applications/
118+
'';
119+
120+
# add extra args to wrapGAppsHook3 wrapper
121+
preFixup = ''
122+
gappsWrapperArgs+=(
123+
--prefix PATH : ${
124+
lib.makeBinPath [
125+
# `defguard-service` needs `ip` to manage wireguard
126+
pkgs.iproute2
127+
# `defguard-client` needs `update-desktop-database`
128+
pkgs.desktop-file-utils
129+
]
130+
}
131+
--prefix LD_LIBRARY_PATH : ${
132+
lib.makeLibraryPath [
133+
pkgs.libayatana-appindicator
134+
]
135+
}
136+
)
137+
'';
138+
139+
meta = with lib; {
140+
description = "Defguard VPN Client";
141+
homepage = "https://defguard.net";
142+
# license = licenses.gpl3Only;
143+
maintainers = with maintainers; [ ];
144+
platforms = platforms.linux;
145+
};
146+
})

0 commit comments

Comments
 (0)