{ description = "Logos Bible Software — Electron wrapper + WINE installer for NixOS"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; dataDir = "$HOME/.local/share/logos-app"; # ── Electron web wrapper ────────────────────────── logos-web = pkgs.writeShellApplication { name = "logos-web"; runtimeInputs = [ pkgs.electron ]; text = '' mkdir -p "${dataDir}" exec electron "${./main.js}" ''; }; # ── WINE launcher (self-bootstrapping) ──────────── logos = pkgs.writeShellApplication { name = "logos"; runtimeInputs = with pkgs; [ wineWow64Packages.stagingFull winetricks wget ]; text = '' WINEPREFIX="''${WINEPREFIX:-$HOME/.local/share/logos-wine}" export WINEPREFIX WINEARCH=win64 LOGOS_EXE="$WINEPREFIX/drive_c/users/$USER/AppData/Local/Logos/Logos.exe" # ── Self-bootstrap: create prefix if missing ── if [ ! -d "$WINEPREFIX" ]; then echo "═══ First run: initializing WINE prefix ═══" wineboot -i && wineserver -w winecfg -v win10 winetricks -q corefonts 2>/dev/null echo "✓ WINE prefix ready" echo "" fi # ── Self-bootstrap: download + run installer if Logos missing ── if [ ! -f "$LOGOS_EXE" ]; then echo "═══ Logos not installed — launching installer ═══" INSTALLER="''${XDG_CACHE_HOME:-$HOME/.cache}/LogosSetup.exe" mkdir -p "$(dirname "$INSTALLER")" if [ ! -f "$INSTALLER" ]; then echo "Downloading installer..." wget -q --show-progress -O "$INSTALLER" \ "https://downloads.logoscdn.com/LBS10/Installer/LogosSetup.exe" fi echo "" echo "→ Follow the Logos setup wizard to sign in and download your library." echo "→ Next time you run 'logos' it will launch directly." echo "" wine "$INSTALLER" || { echo "Installer exited. If Logos is installed, re-run 'logos'." exit 1 } fi if [ -f "$LOGOS_EXE" ]; then exec wine "$LOGOS_EXE" "$@" else echo "Logos not found after install. Try running again." exit 1 fi ''; }; # ── Desktop entries ──────────────────────────────── logos-desktop = pkgs.makeDesktopItem { name = "logos"; exec = "logos"; icon = "logos"; desktopName = "Logos Bible Software"; comment = "Bible study and research (WINE)"; categories = [ "Education" "Office" ]; terminal = false; }; logos-web-desktop = pkgs.makeDesktopItem { name = "logos-web"; exec = "logos-web"; icon = "logos-web"; desktopName = "Logos (Web)"; comment = "Logos web app wrapper"; categories = [ "Education" "Office" ]; terminal = false; }; in { packages = { default = logos; logos = logos; logos-web = logos-web; logos-full = pkgs.symlinkJoin { name = "logos-full"; paths = [ logos logos-web logos-desktop logos-web-desktop ]; }; }; apps = { default = { type = "app"; program = "${logos}/bin/logos"; }; web = { type = "app"; program = "${logos-web}/bin/logos-web"; }; }; devShells.default = pkgs.mkShell { packages = with pkgs; [ wineWow64Packages.stagingFull winetricks electron ]; }; } ); }