cloudflare-warp: add headless variant

This commit is contained in:
ljxfstorm
2025-08-26 18:46:07 +08:00
parent 8d9f0a3c2e
commit c8efaed5bb
+32 -12
View File
@@ -20,6 +20,7 @@
jq,
ripgrep,
common-updater-scripts,
headless ? false,
}:
let
@@ -38,7 +39,7 @@ in
stdenv.mkDerivation rec {
inherit version;
pname = "cloudflare-warp";
pname = "cloudflare-warp" + lib.optionalString headless "-headless";
src =
sources.${stdenv.hostPlatform.system}
@@ -49,20 +50,24 @@ stdenv.mkDerivation rec {
autoPatchelfHook
versionCheckHook
makeWrapper
]
++ lib.optionals (!headless) [
copyDesktopItems
desktop-file-utils
];
buildInputs = [
dbus
gtk3
libpcap
openssl
nss
(lib.getLib stdenv.cc.cc)
]
++ lib.optionals (!headless) [
gtk3
];
desktopItems = [
desktopItems = lib.optionals (!headless) [
(makeDesktopItem {
name = "com.cloudflare.WarpCli";
desktopName = "Cloudflare Zero Trust Team Enrollment";
@@ -93,22 +98,35 @@ stdenv.mkDerivation rec {
mv lib/systemd/system $out/lib/systemd/
substituteInPlace $out/lib/systemd/system/warp-svc.service \
--replace-fail "ExecStart=" "ExecStart=$out"
substituteInPlace $out/lib/systemd/user/warp-taskbar.service \
--replace-fail "ExecStart=" "ExecStart=$out" \
--replace-fail "BindsTo=" "PartOf="
${lib.optionalString (!headless) ''
substituteInPlace $out/lib/systemd/user/warp-taskbar.service \
--replace-fail "ExecStart=" "ExecStart=$out" \
--replace-fail "BindsTo=" "PartOf="
cat >>$out/lib/systemd/user/warp-taskbar.service <<EOF
cat >>$out/lib/systemd/user/warp-taskbar.service <<EOF
[Service]
BindReadOnlyPaths=$out:/usr:
EOF
[Service]
BindReadOnlyPaths=$out:/usr:
EOF
''}
${lib.optionalString headless ''
# For headless version, remove GUI components
rm $out/bin/warp-taskbar
rm -r $out/lib/systemd/user
rm -r $out/etc
rm -r $out/share/applications
rm -r $out/share/icons
rm -r $out/share/warp
''}
runHook postInstall
'';
postInstall = ''
wrapProgram $out/bin/warp-svc --prefix PATH : ${lib.makeBinPath [ nftables ]}
wrapProgram $out/bin/warp-cli --prefix PATH : ${lib.makeBinPath [ desktop-file-utils ]}
${lib.optionalString (!headless) ''
wrapProgram $out/bin/warp-cli --prefix PATH : ${lib.makeBinPath [ desktop-file-utils ]}
''}
'';
doInstallCheck = true;
@@ -146,7 +164,9 @@ stdenv.mkDerivation rec {
};
meta = with lib; {
description = "Replaces the connection between your device and the Internet with a modern, optimized, protocol";
description =
"Replaces the connection between your device and the Internet with a modern, optimized, protocol"
+ lib.optionalString headless " (headless version)";
homepage = "https://pkg.cloudflareclient.com/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree;