···666666 The same thing applies to `cabal configure`, of course, if you're
667667 building with `cabal-install` instead of Stack.
668668669669+## Creating statically linked binaries
670670+671671+There are two levels of static linking. The first option is to configure the
672672+build with the Cabal flag `--disable-executable-dynamic`. In Nix expressions,
673673+this can be achieved by setting the attribute:
674674+675675+ enableSharedExecutables = false;
676676+677677+That gives you a binary with statically linked Haskell libraries and
678678+dynamically linked system libraries.
679679+680680+To link both Haskell libraries and system libraries statically, the additional
681681+flags `--ghc-option=-optl=-static --ghc-option=-optl=-pthread` need to be used.
682682+In Nix, this is accomplished with:
683683+684684+ configureFlags = [ "--ghc-option=-optl=-static" "--ghc-option=-optl=-pthread" ];
685685+686686+It's important to realize, however, that most system libraries in Nix are built
687687+as shared libraries only, i.e. there is just no static library available that
688688+Cabal could link!
689689+669690670691# Other resources
671692