nsis
DSL for producing Windows Installer using NSIS.
https://github.com/ndmitchell/nsis#readme
LTS Haskell 22.39: | 0.3.3 |
Stackage Nightly 2024-10-29: | 0.3.3 |
Latest on Hackage: | 0.3.3 |
nsis-0.3.3@sha256:c5deec46d569f6958a9847bea8d7870b8d300ec744d6ab8c4af4ac4fdd54c22a,2395
Module documentation for 0.3.3
NSIS Manual
This library makes it easier to write NSIS Windows Installers. You should use this library if:
- You want to write a Windows Installer, and have picked NSIS (which is a common choice, and in my opinion, one of the best installer generators for Windows).
The original NSIS tool requires you to write a script in a custom programming language. This library lets you write a Haskell program using special functions that generates an NSIS script. Using this library is better because:
- MUI2 by default: As NSIS has evolved there are now three separate ways to define your user interface, using the Classic builtin commands, using MUI1 or using MUI2. Of these, MUI2 is by far the nicest and should always be used, but the Classic interface is far easier to use. My library always uses MUI2 and makes it easy to use.
- Flow control: NSIS installer scripts are written in a goto-orientated assembly language, making it hard to write any meaningful programs. In contrast, my library presents an imperative statement/expression language. Scripts end up significantly shorter and more readable.
- Variables: The original NSIS system has global mutable variables, 16 register variables and a stack - it directly mirrors assembly programming. In my system, variables are properly scoped and named.
If your script is simple it is likely to look relatively similar in either system. If your script is complex it could end up 100 lines shorter and far clearer in my system. As an illustrative example, let’s warn before installing into the Windows directory or the System directory. In original NSIS this would be:
StrCmp $WINDIR $INSTDIR bad 0
StrCmp $SYSDIR $INSTDIR bad 0
Goto skip
bad:
MessageBox MBOK|MB_ICON_EXCLAMATION "Warning: installing into the Windows directory"
skip:
Using this library we can write:
iff_ ("$INSTDIR" %== "$WINDIR" %|| "$INSTDIR" %== "$SYSDIR") $
alert "Warning: installing into the Windows directory"
A Simple Example
The Examples directory contains a number of simple NSIS scripts, several ported from the NSIS distributed examples. As a simple example:
import Development.NSIS
main = writeFile "example1.nsi" $ nsis $ do
name "Example1" -- The name of the installer
outFile "example1.exe" -- Where to produce the installer
installDir "$DESKTOP/Example1" -- The default installation directory
requestExecutionLevel User -- Request application privileges for Windows Vista
-- Pages to display
page Directory -- Pick where to install
page InstFiles -- Give a progress bar while installing
-- Groups fo files to install
section "" [] $ do
setOutPath "$INSTDIR" -- Where to install files in this section
file [] "Example1.hs" -- File to put into this section
Running this code will generate a file example1.nsi
that can be processed with makensis
to produce the installer example1.exe
. Documentation on each of the functions is available here.
Contributions welcome
I welcome contributions. Some things you could help with:
- I currently wrap most of the standard NSIS functions, but not all of them. I welcome any additional wrappers. I have been wrapping functions by need, but eventually would like to have everything wrapped.
- The functions are mostly intended to be understood in conjunction with the NSIS documentation. I welcome any enhanced documented or work to make the documentation standalone, so people don’t need to look at the underlying NSIS docs.
- I currently wrap 2 plugins - one I needed and one that made a good demo. I welcome wrappers for all plugins.
I have written this library to address my needs. I would welcome bug reports or pull requests, in particular if you can write the installer you need in NSIS but not in this library.
Changes
0.3.3, released 2019-05-15
Add Welcome page
0.3.2, released 2017-11-24
Support Semigroup class
0.3.1, released 2017-02-21
#11, add unsafeInject and unsafeInjectGlobal
#10, add unicode function
0.3, released 2015-06-24
Make strCheck take a message
Add a plugin for helping with radio button
Make constant force an evaluation
Make section return the section id
Generalise the type of nsis
Add a radio button example
0.2.5, released 2015-03-17
Support OName on file
0.2.4, released 2014-12-09
#3, clone the EnvVarUpdate plugin
Add abort
Add strCheck function
Add strIsSuffixOf
Fix strIsPrefixOf
Add writeRegExpandStr
Expose some window functions findWindow, getDlgItem, sendMessage
Add WinMessages plugin/header
Remove upper bounds
#2, add setDetailsPrint
Add support for parameters to the finish page
0.2.3, released 2013-11-04
Add explicit page events
#1, add a Win7 taskbar progress plugin module
Collapse duplicate events into one
Hook up Show/Pre/Leave functions for pages
Add sleep
Add a wrapper round the Base64 plugin
Add support for plugins
Switch to cabal test support, requires Cabal-1.10
Add sectionGet and sectionSet
Add all the binary operations as instances of Bit
Add event and onSelChange
Add execWait and execShell
Add envVar
Add copyFiles function
0.2.2, released 2013-04-16
Change writeFileLines' to not build up a large buffer
0.2.1, released 2013-03-17
#592, make the License page take a license file
0.2, released 2013-01-14
Add Applicative instance for Action
Add str, int and bool functions
0.1.2, released 2012-03-25
Allow transformers-0.3.0.0
0.1.1, released 2012-03-04
Improved documentation
Remove findOnce, you can use fileExists instead
0.1, released 2012-03-04
Start of changelog