Files
DarkRoom/packaging/windows/darkroom.nsi
T
dtourolle cb97ebe7ac Ship the OpenVINO and WebGPU runtimes in every desktop package
The Windows installer and the Flatpak carried no ONNX Runtime, so they
ran every model on tract's one core; the Arch package left it to an
optional dependency. Each now installs two builds under runtimes/ —
Intel's OpenVINO build and the generic WebGPU one, both with the CPU
provider — fetched by tools/fetch-bundled-runtimes.sh from PyPI wheels
pinned by SHA-256, pruned to the native libraries (81 + 31 MB on Linux,
67 + 42 MB on Windows), licence texts beside them.

darkroom-desktop searches runtimes/openvino and runtimes/webgpu under
each place a package installs to; the engine opens all it finds and
keeps the one that fits the GPU, so a CUDA or ROCm runtime installed
beside them still wins on its vendor's card. On Windows the chosen
runtime's directory goes on PATH, because Intel's build leaves OpenVINO's
DLLs for the loader to find there.

The Windows image gains unzip; the installer smoke test checks both
runtimes landed.
2026-10-04 21:00:15 -04:00

150 lines
5.7 KiB
NSIS

; DarkRoom — Windows installer
;
; Built by docker/windows/package.sh with makensis on Linux; see docs/dev/windows.md
; §5 for every decision below. Nothing here is Windows-specific to *write* —
; NSIS has always compiled on POSIX hosts.
;
; makensis -DVERSION=0.12.0 -DSTAGE=/path/to/staging -DOUT=/path/to/setup.exe darkroom.nsi
;
; STAGE holds exactly what §5.2 installs: darkroom.exe, models\, manual\ and
; LICENSE.
; package.sh assembles it and applies the LFS-pointer guard before this runs.
; A 64-bit installer, not NSIS's default 32-bit stub. The application is
; x86_64 only, so nothing is lost; and it means the smoke test runs under a
; 64-bit-only Wine rather than needing an i386 multiarch: the 32-bit stub
; cannot load the WoW64 ntdll there and dies before showing a page.
Target amd64-unicode
Unicode true
SetCompressor /SOLID lzma
!ifndef VERSION
!error "pass -DVERSION=x.y.z"
!endif
!ifndef STAGE
!error "pass -DSTAGE=<staging directory>"
!endif
!ifndef OUT
!error "pass -DOUT=<installer path>"
!endif
!define NAME "DarkRoom"
!define PUBLISHER "Duncan Tourolle"
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
Name "${NAME} ${VERSION}"
OutFile "${OUT}"
; Per-user, no elevation (docs/dev/windows.md §5.1). An unsigned installer that
; also asks for administrator rights is the most alarming thing Windows can
; show, and a per-user install keeps the binaries under the same account as
; the library the application builds.
RequestExecutionLevel user
InstallDir "$LOCALAPPDATA\Programs\${NAME}"
InstallDirRegKey HKCU "${UNINST_KEY}" "InstallLocation"
; The resource block the executable itself carries (`winresource` in
; darkroom-desktop's build.rs) is what Explorer shows for the application;
; this is what it shows for the installer.
VIProductVersion "${VERSION}.0"
VIAddVersionKey "ProductName" "${NAME}"
VIAddVersionKey "ProductVersion" "${VERSION}"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "CompanyName" "${PUBLISHER}"
VIAddVersionKey "LegalCopyright" "GPL-3.0-or-later"
VIAddVersionKey "FileDescription" "${NAME} installer"
!include "MUI2.nsh"
!define MUI_ABORTWARNING
; The GPL, shown rather than linked, for the same reason faces.md §2.2 gives
; for the model grant: the moment it can still change a decision.
!insertmacro MUI_PAGE_LICENSE "${STAGE}\LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section "DarkRoom" SecMain
SectionIn RO
SetOutPath "$INSTDIR"
File "${STAGE}\darkroom.exe"
File "${STAGE}\LICENSE"
; The ten model files (seven face, three scene), beside the executable,
; which is where `library::system_face_models_dirs` looks on Windows —
; last, after the user's own directories, exactly as /usr/share is on Linux.
SetOutPath "$INSTDIR\models"
File /r "${STAGE}\models\*"
; The manual and its pictures, opened by Help and by the help sheet's
; "See it" links (dr_ui::manual). Beside the executable for the same reason
; the models are: it is the one directory the application can find without
; asking the registry.
SetOutPath "$INSTDIR\manual"
File /r "${STAGE}\manual\*"
; ONNX Runtime, twice: Intel's OpenVINO build and the WebGPU build. The
; application opens both and keeps the one that fits the GPU
; (docs/dev/inference.md §3.2); each also runs the models on every core.
SetOutPath "$INSTDIR\runtimes"
File /r "${STAGE}\runtimes\*"
WriteUninstaller "$INSTDIR\uninstall.exe"
; Add/Remove Programs. HKCU, to match the per-user install.
WriteRegStr HKCU "${UNINST_KEY}" "DisplayName" "${NAME}"
WriteRegStr HKCU "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
WriteRegStr HKCU "${UNINST_KEY}" "Publisher" "${PUBLISHER}"
WriteRegStr HKCU "${UNINST_KEY}" "InstallLocation" "$INSTDIR"
WriteRegStr HKCU "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\darkroom.exe"
WriteRegStr HKCU "${UNINST_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKCU "${UNINST_KEY}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S'
WriteRegDWORD HKCU "${UNINST_KEY}" "NoModify" 1
WriteRegDWORD HKCU "${UNINST_KEY}" "NoRepair" 1
CreateDirectory "$SMPROGRAMS\${NAME}"
CreateShortcut "$SMPROGRAMS\${NAME}\${NAME}.lnk" "$INSTDIR\darkroom.exe"
CreateShortcut "$SMPROGRAMS\${NAME}\Uninstall ${NAME}.lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section "Desktop shortcut" SecDesktop
CreateShortcut "$DESKTOP\${NAME}.lnk" "$INSTDIR\darkroom.exe"
SectionEnd
; Off by default: a desktop icon is the user's to ask for.
Function .onInit
SectionSetFlags ${SecDesktop} 0
FunctionEnd
Section "Uninstall"
; What the installer wrote, and nothing the application wrote
; (docs/dev/windows.md §5.3): %LOCALAPPDATA%\darkroom and %APPDATA%\darkroom —
; the catalog, the thumbnails, the face index, the settings — stay. An
; uninstaller that deletes a library index the user spent two hours
; building is the destructive default this project argues against
; everywhere else, so the confirm page says where those directories are.
Delete "$INSTDIR\darkroom.exe"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\uninstall.exe"
RMDir /r "$INSTDIR\models"
RMDir /r "$INSTDIR\manual"
RMDir /r "$INSTDIR\runtimes"
RMDir "$INSTDIR"
Delete "$SMPROGRAMS\${NAME}\${NAME}.lnk"
Delete "$SMPROGRAMS\${NAME}\Uninstall ${NAME}.lnk"
RMDir "$SMPROGRAMS\${NAME}"
Delete "$DESKTOP\${NAME}.lnk"
DeleteRegKey HKCU "${UNINST_KEY}"
SectionEnd
Function un.onInit
MessageBox MB_OKCANCEL|MB_ICONINFORMATION \
"This removes the ${NAME} program.$\r$\n$\r$\nYour library index and settings are kept, in:$\r$\n $LOCALAPPDATA\darkroom$\r$\n $APPDATA\darkroom" \
/SD IDOK IDOK done
Abort
done:
FunctionEnd