$ nix-build -E "with (import <nixpkgs> {}).pkgs; haskellPackages.callPackage ./. {}"
...
$ ldd /nix/store/pd6ax4qhldi79vkilxy8246l7pz7l59f-static-haskell-0.1.0.0/bin/main
not a dynamic executable
$ /nix/store/pd6ax4qhldi79vkilxy8246l7pz7l59f-static-haskell-0.1.0.0/bin/main
"hi"
Last active
August 2, 2017 21:05
-
-
Save teh/f4b45ba1ac46f0ae618c05739570d026 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ mkDerivation, stdenv, haskell, glibc, gmp, bytestring | |
}: | |
let gmp-static = gmp.override { withStatic = true; }; | |
in mkDerivation { | |
pname = "static-haskell"; | |
version = "0.1.0.0"; | |
src = ./.; | |
isLibrary = false; | |
isExecutable = true; | |
configureFlags = [ | |
"--ghc-option=-optl=-static" | |
"--ghc-option=-optl=-pthread" | |
"--extra-lib-dirs=${glibc.static}/lib" | |
"--extra-lib-dirs=${gmp-static}/lib" | |
]; | |
executableHaskellDepends = [ | |
bytestring | |
]; | |
license = stdenv.lib.licenses.gpl3; | |
enableSharedExecutables = false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
main = print "hi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: static-haskell-nix | |
version: 0.1.0.0 | |
dependencies: | |
- base >=4.9 && <5 | |
executables: | |
main: | |
main: Main.hs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This file has been generated from package.yaml by hpack version 0.17.0. | |
-- | |
-- see: https://github.com/sol/hpack | |
name: static-haskell-nix | |
version: 0.1.0.0 | |
build-type: Simple | |
cabal-version: >= 1.10 | |
executable main | |
main-is: Main.hs | |
build-depends: | |
base >=4.9 && <5 | |
default-language: Haskell2010 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment