nsis: DSL for producing Windows Installer using NSIS.

[ bsd3, development, library ] [ Propose Tags ] [ Report a vulnerability ]

NSIS (Nullsoft Scriptable Install System, http://nsis.sourceforge.net/) is a tool that allows programmers to create installers for Windows. This library provides an alternative syntax for NSIS scripts, as an embedded Haskell language, removing much of the hard work in developing an install script. Simple NSIS installers should look mostly the same, complex ones should be significantly more maintainable.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.3, 0.3.1, 0.3.2, 0.3.3
Change log CHANGES.txt
Dependencies base (>=4 && <5), semigroups (>=0.18), transformers (>=0.2), uniplate (>=1.5) [details]
Tested with ghc ==8.6.5, ghc ==8.4.4, ghc ==8.2.2, ghc ==8.0.2, ghc ==7.10.3
License BSD-3-Clause
Copyright Neil Mitchell 2012-2019
Author Neil Mitchell <ndmitchell@gmail.com>
Maintainer Neil Mitchell <ndmitchell@gmail.com>
Category Development
Home page https://github.com/ndmitchell/nsis#readme
Bug tracker https://github.com/ndmitchell/nsis/issues
Source repo head: git clone https://github.com/ndmitchell/nsis.git
Uploaded by NeilMitchell at 2019-05-15T12:57:58Z
Distributions LTSHaskell:0.3.3, NixOS:0.3.3, Stackage:0.3.3
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 12242 total (40 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-05-15 [all 1 reports]

Readme for nsis-0.3.3

[back to package description]

NSIS Manual Hackage version Stackage version Build status

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.