From d7419bcf3b8aacde42b23a2bf1655a97dd08cf62 Mon Sep 17 00:00:00 2001 From: brian Date: Sat, 7 Mar 2026 09:15:30 -0500 Subject: [PATCH] added module options --- default.nix | 4 +++- patch-lib.py | 28 ++++++++++++++++++++++++++++ pinepods-module.nix | 24 ++++++++++++++++++++++++ pinepods.nix | 13 ++++++++----- 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 patch-lib.py create mode 100644 pinepods-module.nix diff --git a/default.nix b/default.nix index c3182ef..8cc30b3 100644 --- a/default.nix +++ b/default.nix @@ -2,10 +2,12 @@ let nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-25.11"; pkgs = import nixpkgs { config = {}; overlays = []; }; in +{ serverUrl ? "" }: { pinepods = pkgs.callPackage ./pinepods.nix { # Pin wasm-bindgen-cli to exactly the version PinePods requires wasm-bindgen-cli = pkgs.wasm-bindgen-cli_0_2_105; - inherit (pkgs) binaryen tailwindcss_3 libayatana-appindicator gst_all_1; + inherit (pkgs) binaryen tailwindcss_3 libayatana-appindicator gst_all_1 python3; + inherit serverUrl; }; } diff --git a/patch-lib.py b/patch-lib.py new file mode 100644 index 0000000..efc1414 --- /dev/null +++ b/patch-lib.py @@ -0,0 +1,28 @@ +import sys + +target = '.run(tauri::generate_context!())' +replacement = '''.setup(|app| { + if let Ok(server_url) = std::env::var("PINEPODS_SERVER") { + if !server_url.is_empty() { + use tauri::Manager; + let window = app.get_webview_window("main").unwrap(); + window.navigate(server_url.parse().unwrap()).unwrap(); + } + } + Ok(()) + }) + .run(tauri::generate_context!())''' + +with open(sys.argv[1], 'r') as f: + content = f.read() + +if target not in content: + print(f"ERROR: Could not find target string in {sys.argv[1]}") + sys.exit(1) + +content = content.replace(target, replacement) + +with open(sys.argv[1], 'w') as f: + f.write(content) + +print("Successfully patched lib.rs") \ No newline at end of file diff --git a/pinepods-module.nix b/pinepods-module.nix new file mode 100644 index 0000000..ba5b2f1 --- /dev/null +++ b/pinepods-module.nix @@ -0,0 +1,24 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.pinepods; + pinepods-pkg = (import "${toString ./.}/default.nix" { + serverUrl = cfg.server; + }).pinepods; +in +{ + options.services.pinepods = { + enable = lib.mkEnableOption "PinePods podcast manager"; + + server = lib.mkOption { + type = lib.types.str; + default = ""; + example = "https://pinepods.example.com"; + description = "The URL of your PinePods server."; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ pinepods-pkg ]; + }; +} \ No newline at end of file diff --git a/pinepods.nix b/pinepods.nix index e6ea5a1..35d79ff 100644 --- a/pinepods.nix +++ b/pinepods.nix @@ -26,6 +26,8 @@ , makeWrapper , libayatana-appindicator , gst_all_1 +, python3 +, serverUrl ? "" }: let @@ -96,6 +98,7 @@ rustPlatform.buildRustPackage { pkg-config wrapGAppsHook3 makeWrapper + python3 ]; buildInputs = [ @@ -128,12 +131,11 @@ rustPlatform.buildRustPackage { preBuild = '' chmod -R u+w $NIX_BUILD_TOP/source - - # Link the pre-built frontend where tauri.conf.json expects it ln -s ${frontend} $NIX_BUILD_TOP/source/web/dist - - # Remove devUrl so Tauri serves embedded assets instead of connecting to a dev server 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 = '' @@ -187,7 +189,8 @@ rustPlatform.buildRustPackage { postFixup = '' wrapProgram $out/bin/pinepods \ --set WEBKIT_DISABLE_COMPOSITING_MODE 1 \ - --set WEBKIT_FORCE_SANDBOX 0 \ + --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" \ -- 2.49.1