diff --git a/nix/sources.json b/nix/sources.json index cf6d31f..5db5bad 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -22,5 +22,17 @@ "type": "tarball", "url": "https://github.com/NixOS/nixpkgs/archive/65c9cc79f1d179713c227bf447fb0dac384cdcda.tar.gz", "url_template": "https://github.com///archive/.tar.gz" + }, + "static-haskell-nix": { + "branch": "master", + "description": "easily build most Haskell programs into fully static Linux executables", + "homepage": "", + "owner": "nh2", + "repo": "static-haskell-nix", + "rev": "382150290ba43b6eb41981c1ab3b32aa31798140", + "sha256": "0zsyplzf1k235rl26irm27y5ljd8ciayw80q575msxa69a9y2nvd", + "type": "tarball", + "url": "https://github.com/nh2/static-haskell-nix/archive/382150290ba43b6eb41981c1ab3b32aa31798140.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/project.nix b/project.nix index b5dbed8..106abb8 100644 --- a/project.nix +++ b/project.nix @@ -1,30 +1,35 @@ { compiler ? "ghc865", sources ? import ./nix/sources.nix }: let - config = { - packageOverrides = pkgs: rec { - haskell = pkgs.haskell // { - packages = pkgs.haskell.packages // { - "${compiler}" = pkgs.haskell.packages."${compiler}".override { - overrides = haskellPackagesNew: haskellPackagesOld: rec { - envy = haskellPackagesNew.callPackage ./nix/envy.nix {}; # old version (< 2) depended on by envy - hal = pkgs.haskell.lib.markUnbroken haskellPackagesOld.hal; - telegram-api = haskellPackagesNew.callPackage ./nix/haskell-telegram-api.nix {}; # patched version from git repo - halma = haskellPackagesNew.callPackage ./halma/halma.nix {}; - halma-telegram-bot = haskellPackagesNew.callPackage ./halma-telegram-bot/halma-telegram-bot.nix {}; - servant-server = pkgs.haskell.lib.dontCheck haskellPackagesOld.servant-server; # tests fail to compile - }; - }; + nonStaticPkgs = + with + { overlay = _: pkgs: { niv = import sources.niv {}; }; }; + import sources.nixpkgs { overlays = [ overlay ]; }; + + staticPkgs = (import "${sources.static-haskell-nix}/survey/default.nix" { compiler = compiler; normalPkgs = nonStaticPkgs; }).pkgs; + haskellLib = staticPkgs.haskell.lib; + + staticHaskellPkgs = staticPkgs.haskell.packages.${compiler}.override { + overrides = haskellPackagesNew: haskellPackagesOld: rec { + envy = haskellPackagesNew.callPackage ./nix/envy.nix {}; # old version (< 2) depended on by envy + hal = haskellLib.markUnbroken haskellPackagesOld.hal; + telegram-api = haskellPackagesNew.callPackage ./nix/haskell-telegram-api.nix {}; # patched version from git repo + halma = haskellPackagesNew.callPackage ./halma/halma.nix {}; + halma-telegram-bot = haskellLib.overrideCabal + (haskellLib.justStaticExecutables (haskellPackagesNew.callPackage ./halma-telegram-bot/halma-telegram-bot.nix {})) + { + configureFlags = [ + "--ghc-option=-optl=-static" + "--extra-lib-dirs=${staticPkgs.gmp6.override { withStatic = true; }}/lib" + "--extra-lib-dirs=${staticPkgs.zlib.static}/lib" + "--extra-lib-dirs=${staticPkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib" + #"--disable-executable-stripping" + ]; }; - }; + servant-server = haskellLib.dontCheck haskellPackagesOld.servant-server; # tests fail to compile }; }; - pkgs = - with - { overlay = _: pkgs: { niv = import sources.niv {}; }; }; - import sources.nixpkgs { overlays = [ overlay ]; inherit config; }; - in - { halma-telegram-bot = pkgs.haskell.packages.${compiler}.halma-telegram-bot; + { halma-telegram-bot = staticHaskellPkgs.halma-telegram-bot; } \ No newline at end of file