2020-06-23 20:06:50 +02:00
{
# Compiler in a form ghc8101 == GHC 8.10.1, just remove spaces and dots
compiler ? " g h c 8 8 3 "
2018-05-15 21:16:02 +02:00
2020-06-03 19:51:04 +02:00
# This settings expose most of the Nixpkgs Haskell.lib API: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/lib.nix
# Some of these options implicitly enable other options they require, and some counterpoint options clash, obviously
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-24 02:05:05 +02:00
2020-06-03 19:34:04 +02:00
# Just produce a SDist src tarball
, sdistTarball ? false
2020-06-24 02:19:10 +02:00
# The strict packaging process as used on Hackage. Tests consistency of the Cabal file.
2020-06-03 19:35:20 +02:00
, buildFromSdist ? true
2020-06-24 02:05:05 +02:00
2020-06-24 02:19:10 +02:00
# Turn all warn into err with {-Wall,-Werror}
2020-06-03 19:36:42 +02:00
, failOnAllWarnings ? false
2020-06-03 19:37:26 +02:00
# `failOnAllWarnings` + `buildFromSdist`
, buildStrictly ? false
2020-06-24 02:05:05 +02:00
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
, enableDeadCodeElimination ? false
2020-06-24 02:19:10 +02:00
# Disabled GHC code optimizations make build/tolling/dev loops faster.
# Works also for Haskel IDE Engine and GHCID.
# Enable optimizations for production use, and to pass benchmarks.
2020-06-03 19:37:57 +02:00
, 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-06-24 02:05:05 +02:00
2020-06-03 21:17:05 +02:00
# Provide an inventory of performance events and timings for the execution. Provides informaiton in an absolute sense. Nothing is timestamped.
2020-05-31 16:04:15 +02:00
, enableLibraryProfiling ? false
, enableExecutableProfiling ? false
2020-06-03 21:17:05 +02:00
# Include tracing information & abilities. Tracing records the chronology, often with timestamps and is extensive in time
2018-04-24 01:39:37 +02:00
, doTracing ? 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-24 02:05:05 +02:00
2020-06-03 21:17:05 +02:00
# Nixpkgs expects shared libraries
2020-05-31 21:48:41 +02:00
, enableSharedLibraries ? true
2020-06-03 21:17:05 +02:00
# Ability to make static libraries
2020-05-31 21:48:41 +02:00
, enableStaticLibraries ? false
2020-06-03 19:09:49 +02:00
# Make hybrid executable that is also a shared library
, enableSharedExecutables ? false
2020-06-03 21:17:05 +02:00
# link executables statically against haskell libs to reduce closure size
2020-05-31 21:48:41 +02:00
, justStaticExecutables ? false
2020-06-03 19:25:54 +02:00
, enableSeparateBinOutput ? false
2020-06-24 02:05:05 +02:00
2020-06-24 02:19:10 +02:00
# checkUnusedPackages: is `failOnAllWarnings` + `cabal sdist` + post-build dep check.
# Currently uses `packunused` or GHC 8.8 internals, later switches into GHC internal feature.
# Adds a post-build check to verify that dependencies declared in the cabal file are actually used.
2020-06-03 19:42:18 +02:00
, checkUnusedPackages ? false
2020-06-03 19:09:49 +02:00
# Generation and installation of haddock API documentation
, doHaddock ? false
2020-06-24 02:05:05 +02:00
# Generate hyperlinked source code for documentation using HsColour, and have Haddock documentation link to it.
, doHyperlinkSource ? false
2020-06-03 19:09:49 +02:00
# 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-24 02:19:10 +02:00
# For binaries named in `executableNamesToShellComplete` list, generate and bundle-into package an automatically loaded shell complettions
2020-06-17 18:40:21 +02:00
, generateOptparseApplicativeCompletions ? false
, executableNamesToShellComplete ? [ " h n i x " ]
2018-05-15 21:16:02 +02:00
2020-06-24 02:05:05 +02:00
2020-06-24 02:19:10 +02:00
# Include Hoogle into derivation
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
2020-06-24 02:11:05 +02:00
# Nix by default uses nixpkgs-unstable channel
# Nixpkgs revision options:
# `rev` vals in order of freshness -> cache & stability:
# { master
# , <commitHash>
# , haskell-updates # Haskell development branch in Nixpkgs, can be inconsistent. Weekly merged into the upstream
# , nixpkgs-unstable # Default branch on Nix installation, default for non NixOS
# , nixos-unstable # nixpkgs-unstable that passes a bunch of base tests
# , nixos-20.03 # Last stable release, gets almost no updates to recipes, gets only required backports
# ...
# }
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.";
# });
# };
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 21:14:10 +02:00
# Application of functions from this list to the package in code here happens in the reverse order (from the tail). Some options depend on & override others, so if enabling options caused Nix error or not expected result - change the order, and please do not change this order without proper testing.
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
{
2020-06-17 18:40:21 +02:00
switch = generateOptparseApplicativeCompletions ;
function = pkgs . haskell . lib . generateOptparseApplicativeCompletions executableNamesToShellComplete ;
2020-06-03 19:43:22 +02:00
}
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:14:10 +02:00
# Function that applies enabled option to the package, used in the fold.
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 " ;
2020-06-23 15:38:21 +02:00
root = pkgs . nix-gitignore . gitignoreSource [ ] ./. ;
2020-06-03 19:32:35 +02:00
2020-06-27 10:43:50 +02:00
overrides = self : super : {
# 2020-06-26 Due to a behaviour change in neat-interpolation-0.4, we
# require n-i >= 0.4. dontCheck helps us avoid conflicts with
# neat-interpolation's test dependencies.
neat-interpolation = pkgs . haskell . lib . dontCheck super . neat-interpolation_0_5_1 ;
2020-07-23 02:52:21 +02:00
# 2020-07-23 hnix uses multiple functions that are unavailable in
# data-fix < 0.3.
data-fix = haskellPackages . callPackage
( { mkDerivation , base , deepseq , hashable , stdenv }:
mkDerivation {
pname = " d a t a - f i x " ;
version = " 0 . 3 . 0 " ;
sha256 = " 9 e 5 9 b 3 e d 6 9 4 b 5 1 3 9 3 1 6 0 9 3 b 3 7 6 7 8 4 2 e 6 0 a d 4 8 2 1 8 5 8 4 5 9 e 7 c d 7 6 3 e 5 7 7 3 d f a 9 9 a 0 " ;
libraryHaskellDepends = [ base deepseq hashable ] ;
homepage = " h t t p s : / / g i t h u b . c o m / s p e l l - m u s i c / d a t a - f i x " ;
description = " F i x p o i n t d a t a t y p e s " ;
license = stdenv . lib . licenses . bsd3 ;
} ) { } ;
2020-06-27 10:43:50 +02:00
} ;
2020-06-03 19:32:35 +02:00
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
2020-06-03 19:49:02 +02:00
configureFlags = pkgs . stdenv . lib . optional doTracing " - - f l a g s = t r a c i n g " ;
2020-06-03 19:32:35 +02:00
passthru = {
nixpkgs = pkgs ;
inherit haskellPackages ;
} ;
} ) ;
returnShellEnv = false ;
} ;
2020-06-03 21:14:10 +02:00
# One part of Haskell.lib options are argument switches, those are in `inherit`ed list.
# Other part - are function wrappers over pkg. Fold allows to compose those.
# composePackage = foldr (if switch then function) (package) ([{switch,function}]) == (functionN .. (function1 package))
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