Files
PinePods-nix/pinepods.nix
2026-03-07 09:15:30 -05:00

211 lines
5.6 KiB
Nix

{ lib
, fetchFromGitHub
, rustPlatform
, pkg-config
, wrapGAppsHook3
, llvmPackages
, binaryen
, tailwindcss_3
, webkitgtk_4_1
, gtk3
, glib
, cairo
, gdk-pixbuf
, pango
, atk
, libsoup_3
, librsvg
, dbus
, openssl
, at-spi2-atk
, at-spi2-core
, glib-networking
, gsettings-desktop-schemas
, wasm-bindgen-cli
, trunk
, makeWrapper
, libayatana-appindicator
, gst_all_1
, python3
, serverUrl ? ""
}:
let
pname = "pinepods";
version = "0.8.2";
src = fetchFromGitHub {
owner = "madeofpendletonwool";
repo = "PinePods";
rev = version;
sha256 = "1ivqazhzg3wwlqzz0dv0g48hv265c3qqhvxl02j20361j4mqn6rp";
};
# ── Step 1: Build the Yew/WASM frontend with trunk ──────────────────────────
frontend = rustPlatform.buildRustPackage {
pname = "pinepods-frontend";
inherit version src;
sourceRoot = "source/web";
cargoRoot = ".";
cargoLock = {
lockFile = ./Cargo.frontend.lock;
outputHashes = {
"i18nrs-0.1.7" = "sha256-LEHQ8GI3eVKwhtxetxyIY4HV16TS3D9n+2Hh+sm5j74=";
};
};
nativeBuildInputs = [ trunk wasm-bindgen-cli llvmPackages.lld binaryen tailwindcss_3 ];
buildPhase = ''
cp -r . $NIX_BUILD_TOP/web-build
chmod -R u+w $NIX_BUILD_TOP/web-build
cd $NIX_BUILD_TOP/web-build
mkdir -p dist
export HOME=$NIX_BUILD_TOP
export XDG_CACHE_HOME=$NIX_BUILD_TOP/cache
mkdir -p $NIX_BUILD_TOP/cache
export TRUNK_SKIP_VERSION_CHECK=true
export TRUNK_TOOLS_WASM_BINDGEN=0.2.105
export TRUNK_TOOLS_WASM_OPT=version_124
RUSTFLAGS="--cfg=web_sys_unstable_apis" trunk build --release
'';
installPhase = ''
cp -r $NIX_BUILD_TOP/web-build/dist $out
'';
doCheck = false;
};
in
# ── Step 2: Build the Tauri binary, pointing it at the pre-built frontend ────
rustPlatform.buildRustPackage {
inherit pname version src;
sourceRoot = "source/web/src-tauri";
cargoRoot = ".";
cargoExtraArgs = "--bin app --features custom-protocol";
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [
pkg-config
wrapGAppsHook3
makeWrapper
python3
];
buildInputs = [
openssl
dbus
glib
gtk3
cairo
gdk-pixbuf
pango
atk
at-spi2-atk
at-spi2-core
libsoup_3
webkitgtk_4_1
librsvg
glib-networking
gsettings-desktop-schemas
libayatana-appindicator
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-bad
gst_all_1.gst-plugins-ugly
gst_all_1.gst-libav
];
OPENSSL_NO_VENDOR = "1";
TAURI_SKIP_DEVSERVER_CHECK = "true";
preBuild = ''
chmod -R u+w $NIX_BUILD_TOP/source
ln -s ${frontend} $NIX_BUILD_TOP/source/web/dist
sed -i '/"devUrl"/d' $NIX_BUILD_TOP/source/web/src-tauri/tauri.conf.json
# Patch lib.rs to read PINEPODS_SERVER env var and navigate to it on startup
python3 ${./patch-lib.py} $NIX_BUILD_TOP/source/web/src-tauri/src/lib.rs
'';
installPhase = ''
runHook preInstall
install -Dm755 target/x86_64-unknown-linux-gnu/release/app $out/bin/pinepods
# Desktop entry
if [ -f ../../pinepods.desktop ]; then
install -Dm644 ../../pinepods.desktop \
$out/share/applications/pinepods.desktop
fi
# Icons
for size in 32x32 128x128 256x256; do
if [ -f icons/''${size}.png ]; then
install -Dm644 icons/''${size}.png \
$out/share/icons/hicolor/''${size}/apps/pinepods.png
fi
done
# Tray icon install as the app icon so the taskbar uses it
if [ -f icons/icon.png ]; then
install -Dm644 icons/icon.png \
$out/share/icons/hicolor/256x256/apps/com.gooseberrydevelopment.pinepods.png
fi
# AppStream metadata
if [ -f com.gooseberrydevelopment.pinepods.metainfo.xml ]; then
install -Dm644 com.gooseberrydevelopment.pinepods.metainfo.xml \
$out/share/metainfo/com.gooseberrydevelopment.pinepods.metainfo.xml
fi
# Create desktop entry
mkdir -p $out/share/applications
cat > $out/share/applications/pinepods.desktop << EOF
[Desktop Entry]
Name=Pinepods
Comment=A self-hosted podcast manager
Exec=pinepods
Icon=com.gooseberrydevelopment.pinepods
Type=Application
Categories=Audio;Music;
StartupNotify=true
StartupWMClass=Pinepods
EOF
runHook postInstall
'';
postFixup = ''
wrapProgram $out/bin/pinepods \
--set WEBKIT_DISABLE_COMPOSITING_MODE 1 \
--set WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS 1 \
${lib.optionalString (serverUrl != "") "--set PINEPODS_SERVER \"${serverUrl}\""} \
--prefix LD_LIBRARY_PATH : "${libayatana-appindicator}/lib" \
--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "${gst_all_1.gstreamer}/lib/gstreamer-1.0:${gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0:${gst_all_1.gst-plugins-ugly}/lib/gstreamer-1.0:${gst_all_1.gst-libav}/lib/gstreamer-1.0" \
--prefix XDG_DATA_DIRS : "$out/share" \
--prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}:${gtk3}/share/gsettings-schemas/${gtk3.name}" \
--prefix GIO_EXTRA_MODULES : "${glib-networking}/lib/gio/modules"
'';
doCheck = false;
meta = with lib; {
description = "PinePods desktop client - self-hosted podcast manager (Tauri v2)";
homepage = "https://github.com/madeofpendletonwool/PinePods";
license = licenses.gpl3Only;
platforms = platforms.linux;
mainProgram = "pinepods";
};
}