2020-05-31 16:06:34 +02:00
{ compiler ? " g h c 8 8 3 "
2018-05-15 21:16:02 +02:00
2020-06-03 19:09:49 +02:00
# Don't fail at configure time if there are multiple versions of the same package in the (recursive) dependencies of the package being built. Will delay failures, if any, to compile time.
, allowInconsistentDependencies ? false
# Escape the version bounds from the cabal file. You may want to avoid this function.
, doJailbreak ? false
2020-05-31 22:07:14 +02:00
# Nix dependency checking, compilation and execution of test suites listed in the package description file.
2020-05-31 16:06:34 +02:00
, doCheck ? true
2020-06-03 19:34:04 +02:00
# Just produce a SDist src tarball
, sdistTarball ? false
2020-06-03 19:35:20 +02:00
# Produce SDist tarball and build project from it
, buildFromSdist ? true
2020-06-03 19:36:42 +02:00
, failOnAllWarnings ? false
2020-06-03 19:37:26 +02:00
# `failOnAllWarnings` + `buildFromSdist`
, buildStrictly ? false
2020-06-03 19:09:49 +02:00
# 2020-06-02: NOTE: enableDeadCodeElimination = true: On GHC =< 8.8.3 macOS build falls due to https://gitlab.haskell.org/ghc/ghc/issues/17283
# Disable GHC code optimizations for faster dev loops. Enable optimizations for production use or benchmarks.
, enableDeadCodeElimination ? false
2020-06-03 19:37:57 +02:00
# Optimization disabled for faster compiling/dev loop
, disableOptimization ? true
2020-06-03 19:38:30 +02:00
# Use faster `gold` ELF linker from GNU binutils instead of older&slower but more versatile GNU linker. Is not available by default since macOS does not have it.
, linkWithGold ? false
2020-05-31 16:04:15 +02:00
, enableLibraryProfiling ? false
, enableExecutableProfiling ? false
2018-04-24 01:39:37 +02:00
, doTracing ? false
2020-05-31 22:07:14 +02:00
# Enables GHC optimizations for production use, without optimizations compilation is way faster
, doOptimize ? false
2020-06-03 19:38:58 +02:00
# Include DWARF debugging information & abilities
, enableDWARFDebugging ? true
2020-06-03 19:09:49 +02:00
# Strip results from all debugging symbols
, doStrip ? false
2020-06-03 19:47:31 +02:00
# Generate hyperlinked source code for documentation using HsColour, and have Haddock documentation link to it.
, doHyperlinkSource ? false
2020-05-31 21:48:41 +02:00
, enableSharedLibraries ? true
, enableStaticLibraries ? false
2020-06-03 19:09:49 +02:00
# Make hybrid executable that is also a shared library
, enableSharedExecutables ? false
2020-05-31 21:48:41 +02:00
, justStaticExecutables ? false
2020-06-03 19:25:54 +02:00
, enableSeparateBinOutput ? false
2020-06-03 19:42:18 +02:00
# Add a post-build check to verify that dependencies declared in the .cabal file are actually used.
, checkUnusedPackages ? false
2020-06-03 19:09:49 +02:00
# Generation and installation of haddock API documentation
, doHaddock ? false
# Generation and installation of a coverage report. See https://wiki.haskell.org/Haskell_program_coverage
, doCoverage ? false
# doBenchmark: Dependency checking + compilation and execution for benchmarks listed in the package description file.
, doBenchmark ? false
2020-06-03 19:43:22 +02:00
# Modify a Haskell package to add shell completion scripts for the given executable produced by it. These completion scripts will be picked up automatically if the resulting derivation is installed
, generateOptparseApplicativeCompletion ? false
2018-05-15 21:16:02 +02:00
2019-05-01 02:29:36 +02:00
, withHoogle ? true
2019-02-17 00:39:03 +01:00
2020-06-01 17:55:42 +02:00
, useRev ? false
# Accepts Nixpkgs channel name and Git revision
2020-06-01 17:47:42 +02:00
, rev ? " n i x p k g s - u n s t a b l e "
2018-11-22 18:52:52 +01:00
2020-01-09 03:34:08 +01:00
, pkgs ?
2018-05-15 21:16:02 +02:00
if builtins . compareVersions builtins . nixVersion " 2 . 0 " < 0
then abort " h n i x r e q u i r e s a t l e a s t n i x 2 . 0 "
2020-06-01 17:55:42 +02:00
else
if useRev
2020-06-03 18:45:49 +02:00
# Please do not guard with hash, so the package able to use current channels (rolling `rev`) of Haskell&Nixpkgs
2020-06-01 17:55:42 +02:00
then import ( builtins . fetchTarball " h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / a r c h i v e / ${ rev } . t a r . g z " ) { }
else import <nixpkgs> { }
2020-06-01 17:48:31 +02:00
// {
2020-06-01 17:55:42 +02:00
config . allowBroken = true ;
2020-01-09 03:34:08 +01:00
# config.packageOverrides = pkgs: rec {
# nix = pkgs.nixStable.overrideDerivation (attrs: with pkgs; rec {
# src = if builtins.pathExists ./data/nix/.version
# then data/nix
# else throw "data/nix doesn't seem to contain the nix source. You may want to run git submodule update --init.";
# enableParallelBuilding = true;
# configureFlags =
# [ "--disable-doc-gen"
# "--enable-gc"
# ];
# buildInputs =
# [ bison
# flex
# autoconf-archive
# autoreconfHook
# curl
# bzip2 xz brotli editline
# openssl pkgconfig sqlite boehmgc
# boost
# git
# mercurial
# ]
# ++ lib.optionals stdenv.isLinux [libseccomp utillinuxMinimal]
# ++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
# ++ lib.optional (stdenv.isLinux || stdenv.isDarwin)
# (aws-sdk-cpp.override {
# apis = ["s3" "transfer"];
# customMemoryManagement = false;
# });
# outputs = builtins.filter (s: s != "doc" && s != "man" ) attrs.outputs;
# });
# };
2020-06-01 17:55:42 +02:00
}
2018-11-22 18:52:52 +01:00
2018-11-22 20:21:06 +01:00
, mkDerivation ? null
2018-04-12 05:21:52 +02:00
} :
2018-04-07 01:23:24 +02:00
2019-03-10 01:55:31 +01:00
let
2020-05-23 20:11:23 +02:00
# 2020-05-23: NOTE: Currently HNix-store needs no overlay
# hnix-store-src = pkgs.fetchFromGitHub {
# owner = "haskell-nix";
# repo = "hnix-store";
# rev = "0.2.0.0";
# sha256 = "1qf5rn43d46vgqqgmwqdkjh78rfg6bcp4kypq3z7mx46sdpzvb78";
# };
2019-03-10 01:55:31 +01:00
overlay = pkgs . lib . foldr pkgs . lib . composeExtensions ( _ : _ : { } ) [
2020-05-23 20:11:23 +02:00
# (import "${hnix-store-src}/overlay.nix")
2020-05-23 20:01:26 +02:00
( self : super : with pkgs . haskell . lib ;
pkgs . lib . optionalAttrs withHoogle {
2019-03-10 01:55:31 +01:00
ghc = super . ghc // { withPackages = super . ghc . withHoogle ; } ;
ghcWithPackages = self . ghc . withPackages ;
} )
] ;
overrideHaskellPackages = orig : {
buildHaskellPackages =
orig . buildHaskellPackages . override overrideHaskellPackages ;
overrides = if orig ? overrides
then pkgs . lib . composeExtensions orig . overrides overlay
else overlay ;
} ;
haskellPackages = pkgs . haskell . packages . ${ compiler } . override
overrideHaskellPackages ;
2018-07-25 20:53:48 +02:00
2020-06-03 19:33:14 +02:00
listOfSetsOfSwitchExtend =
[
2020-06-03 19:34:04 +02:00
{
switch = sdistTarball ;
function = pkgs . haskell . lib . sdistTarball ;
}
2020-06-03 19:35:20 +02:00
{
switch = buildFromSdist ;
function = pkgs . haskell . lib . buildFromSdist ;
}
2020-06-03 19:37:26 +02:00
{
switch = buildStrictly ;
function = pkgs . haskell . lib . buildStrictly ;
}
2020-06-03 19:37:57 +02:00
{
switch = disableOptimization ;
function = pkgs . haskell . lib . disableOptimization ;
}
2020-06-03 19:39:43 +02:00
{
switch = doJailbreak ;
function = pkgs . haskell . lib . doJailBreak ;
}
2020-06-03 19:40:47 +02:00
{
switch = doStrip ;
function = pkgs . haskell . lib . doStrip ;
}
2020-06-03 19:38:58 +02:00
{
switch = enableDWARFDebugging ;
function = pkgs . haskell . lib . enableDWARFDebugging ;
}
2020-06-03 19:38:30 +02:00
{
switch = linkWithGold ;
function = pkgs . haskell . lib . linkWithGold ;
}
2020-06-03 19:36:42 +02:00
{
switch = failOnAllWarnings ;
function = pkgs . haskell . lib . failOnAllWarnings ;
}
2020-06-03 19:41:24 +02:00
{
switch = justStaticExecutables ;
function = pkgs . haskell . lib . justStaticExecutables ;
}
2020-06-03 19:42:18 +02:00
{
switch = checkUnusedPackages ;
function = pkgs . haskell . lib . checkUnusedPackages { } ;
}
2020-06-03 19:43:22 +02:00
{
switch = generateOptparseApplicativeCompletion ;
function = pkgs . haskell . lib . generateOptparseApplicativeCompletion " h n i x " ;
}
2020-06-03 19:47:31 +02:00
{
switch = doHyperlinkSource ;
function = pkgs . haskell . lib . doHyperlinkSource ;
}
2020-06-03 19:33:14 +02:00
] ;
2020-06-03 21:13:02 +02:00
funcOnSwitchAppliesFunction = set : object :
2020-06-03 19:33:14 +02:00
if set . switch
then set . function object
else object ;
2020-06-03 19:32:35 +02:00
# General description of package
package = haskellPackages . developPackage {
name = " h n i x " ;
root = ./. ;
modifier = drv : pkgs . haskell . lib . overrideCabal drv ( attrs : {
buildTools = ( attrs . buildTools or [ ] ) ++ [
haskellPackages . cabal-install
] ;
testHaskellDepends = attrs . testHaskellDepends ++ [
pkgs . nix
haskellPackages . criterion
] ;
2020-06-03 19:21:57 +02:00
# Declare that the header set arguments as according Haskell.lib switches
inherit allowInconsistentDependencies ;
2020-06-03 19:32:35 +02:00
inherit doCheck ;
2020-06-03 19:21:57 +02:00
inherit enableDeadCodeElimination ;
2020-06-03 19:32:35 +02:00
inherit enableLibraryProfiling ;
inherit enableExecutableProfiling ;
inherit enableSharedLibraries ;
inherit enableStaticLibraries ;
2020-06-03 19:21:57 +02:00
inherit enableSharedExecutables ;
2020-06-03 19:25:54 +02:00
inherit enableSeparateBinOutput ;
2020-06-03 19:21:57 +02:00
inherit doBenchmark ;
inherit doCoverage ;
inherit doHaddock ;
2020-06-03 19:32:35 +02:00
configureFlags =
pkgs . stdenv . lib . optional doTracing " - - f l a g s = t r a c i n g "
++ pkgs . stdenv . lib . optional doOptimize " - - f l a g s = o p t i m i z e "
passthru = {
nixpkgs = pkgs ;
inherit haskellPackages ;
} ;
} ) ;
returnShellEnv = false ;
} ;
2020-06-03 21:13:02 +02:00
composedPackage = pkgs . lib . foldr ( funcOnSwitchAppliesFunction ) package listOfSetsOfSwitchExtend ;
2020-06-03 19:32:35 +02:00
in composedPackage