Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 26, 2020
1 parent c6b5bb7 commit f300ba9
Showing 1 changed file with 76 additions and 36 deletions.
112 changes: 76 additions & 36 deletions nix/haskell.nix
@@ -1,16 +1,20 @@
############################################################################
# Builds Haskell packages with Haskell.nix
############################################################################
{ lib
{ pkgs
, lib
, stdenv
, pkgs
, haskell-nix
, buildPackages
, config ? {}
# GHC attribute name
, compiler ? config.haskellNix.compiler or "ghc8102"
, compiler
# Enable profiling
, profiling ? config.haskellNix.profiling or false
, profiling ? false
# Enable asserts for given packages
, assertedPackages ? []
# Version info, to be passed when not building from a git work tree
, gitrev ? null
, libsodium ? pkgs.libsodium
}:
let

Expand All @@ -22,58 +26,94 @@ let
projectPackages = lib.attrNames (haskell-nix.haskellLib.selectProjectPackages
(haskell-nix.cabalProject {
inherit src;
compiler-nix-name = compiler;
compiler-nix-name = "ghc8102";
}));

# This creates the Haskell package set.
# https://input-output-hk.github.io/haskell.nix/user-guide/projects/
pkgSet = haskell-nix.cabalProject {
pkgSet = haskell-nix.cabalProject ({
inherit src;
compiler-nix-name = compiler;
cabalProjectLocal = ''
'';
modules = [
# Allow reinstallation of Win32
({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isWindows {
nonReinstallablePkgs =
[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
# ghcjs custom packages
"ghcjs-prim" "ghcjs-th"
"ghc-boot"
"ghc" "array" "binary" "bytestring" "containers"
"filepath" "ghc-boot" "ghc-compact" "ghc-prim"
# "ghci" "haskeline"
"hpc"
"mtl" "parsec" "text" "transformers"
"xhtml"
# "stm" "terminfo"
];
})
{ # ...
}
{
# Stamp executables with the git revision
# And make sure that libsodium DLLs are available for windows binaries:
packages = lib.genAttrs projectPackages (name: {
postInstall = ''
'';
});
}
({ pkgs, config, ... }: {
# Packages we wish to ignore version bounds of.
# This is similar to jailbreakCabal, however it
# does not require any messing with cabal files.
packages.katip.doExactConfig = true;

# Compile all local packages with -Werror:
# split data output for ekg to reduce closure size
packages.ekg.components.library.enableSeparateDataOutput = true;
})
{
packages = lib.genAttrs projectPackages
(name: { configureFlags = [ "--ghc-option=-Werror" ]; });
}
(lib.optionalAttrs profiling {
enableLibraryProfiling = true;
})
{
enableLibraryProfiling = profiling;
packages = lib.genAttrs assertedPackages
(name: { flags.asserts = true; });
}
({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isWindows {
# Allow reinstallation of Win32
nonReinstallablePkgs =
[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
# ghcjs custom packages
"ghcjs-prim" "ghcjs-th"
"ghc-boot"
"ghc" "array" "binary" "bytestring" "containers"
"filepath" "ghc-boot" "ghc-compact" "ghc-prim"
# "ghci" "haskeline"
"hpc"
"mtl" "parsec" "text" "transformers"
"xhtml"
# "stm" "terminfo"
];
# ruby/perl dependencies cannot be cross-built for cddl tests:
packages.cardano-prelude.flags.cddl = false;
({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
# systemd can't be statically linked
packages.cardano-prelude.flags.systemd = !pkgs.stdenv.hostPlatform.isMusl;
})
# Musl libc fully static build
(lib.optionalAttrs stdenv.hostPlatform.isMusl (let
# Module options which adds GHC flags and libraries for a fully static build
fullyStaticOptions = {
enableShared = false;
enableStatic = true;
};
in
{
packages = lib.genAttrs projectPackages (name: fullyStaticOptions);

# Make sure we use a buildPackages version of happy
packages.pretty-show.components.library.build-tools = [ buildPackages.haskell-nix.haskellPackages.happy ];
# Haddock not working and not needed for cross builds
doHaddock = false;
}
))

({ pkgs, ... }: lib.mkIf (pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform) {
# Remove hsc2hs build-tool dependencies (suitable version will be available as part of the ghc derivation)
packages.Win32.components.library.build-tools = lib.mkForce [];
packages.terminal-size.components.library.build-tools = lib.mkForce [];
packages.network.components.library.build-tools = lib.mkForce [];
})
({ pkgs, ... }: lib.mkIf (!pkgs.stdenv.hostPlatform.isWindows) {
packages.cardano-prelude.flags.cddl = true;
packages.cardano-prelude.components.tests.test-cddl.build-tools = [pkgs.cddl pkgs.cbor-diag];
packages.cardano-prelude.components.tests.test-cddl.preCheck = "export HOME=`pwd`";
})
];
configureArgs = lib.optionalString stdenv.hostPlatform.isWindows "--disable-tests";
};
# TODO add flags to packages (like cs-ledger) so we can turn off tests that will
# not build for windows on a per package bases (rather than using --disable-tests).
# configureArgs = lib.optionalString stdenv.hostPlatform.isWindows "--disable-tests";
});
in
pkgSet

0 comments on commit f300ba9

Please sign in to comment.