Files
DarkRoom/packaging/windows/darkroom.nsi
T
dtourolle d8f26fb5cd Ship the manual with the Arch package, the Windows installer and the APK
The rendered manual was in the repository and nowhere else, so an
installed application still had nothing to open.

Each packager now carries docs/manual/index.html and its pictures, to
where the application will look for them: /usr/share/darkroom/manual on
Arch, manual\ beside darkroom.exe on Windows (where the models already
are, and where dr_plat::system_data_dirs points), and assets/manual in
the APK, stored rather than deflated since a GIF or PNG is already
compressed. The manual is about 27 MB, which the APK and the installer
both grow by; the pictures are 1600x1100 screenshots and short GIFs,
and against an APK that already carries 170 MB of inference runtime and
70 MB of models they are not worth re-encoding for.

The pictures are LFS objects, so each packager refuses a pointer where a
picture should be, as it already does for the models: shipped, a pointer
is a manual of broken images that nothing reports. The Android and
Windows CI legs therefore fetch docs/manual/media, which they excluded
while nothing they built read it, and the installer smoke test checks
that the page and every picture were installed.
2026-09-24 22:33:41 -04:00

143 lines
5.4 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\*"
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 "$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