hnix/default.nix

185 lines
6.1 KiB
Nix
Raw Normal View History

{ compiler ? "ghc883"
2018-05-15 21:16:02 +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
# Nix dependency checking, compilation and execution of test suites listed in the package description file.
, doCheck ? true
# Just produce a SDist src tarball
, sdistTarball ? false
# 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
, enableLibraryProfiling ? false
, enableExecutableProfiling ? false
, doTracing ? false
# Enables GHC optimizations for production use, without optimizations compilation is way faster
, doOptimize ? false
2018-04-29 03:21:24 +02:00
, doStrict ? false
# Strip results from all debugging symbols
, doStrip ? false
, enableSharedLibraries ? true
, enableStaticLibraries ? false
, doHyperlinkSource ? false
# Make hybrid executable that is also a shared library
, enableSharedExecutables ? false
, justStaticExecutables ? false
, enableSeparateBinOutput ? false
# 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
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
, useRev ? false
# Accepts Nixpkgs channel name and Git revision
, rev ? "nixpkgs-unstable"
, pkgs ?
2018-05-15 21:16:02 +02:00
if builtins.compareVersions builtins.nixVersion "2.0" < 0
then abort "hnix requires at least nix 2.0"
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
then import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz") {}
else import <nixpkgs> {}
// {
config.allowBroken = true;
# 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;
# });
# };
}
2018-11-22 20:21:06 +01:00
, mkDerivation ? null
}:
2018-04-07 01:23:24 +02:00
2019-03-10 01:55:31 +01:00
let
# 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 (_: _: {}) [
# (import "${hnix-store-src}/overlay.nix")
(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
listOfSetsOfSwitchExtend =
[
{
switch = sdistTarball;
function = pkgs.haskell.lib.sdistTarball;
}
];
funcOnSwitchAppliesFunction = set: object:
if set.switch
then set.function object
else object;
# General description of package
package = haskellPackages.developPackage {
name = "hnix";
root = ./.;
modifier = drv: pkgs.haskell.lib.overrideCabal drv (attrs: {
buildTools = (attrs.buildTools or []) ++ [
haskellPackages.cabal-install
];
testHaskellDepends = attrs.testHaskellDepends ++ [
pkgs.nix
haskellPackages.criterion
];
# Declare that the header set arguments as according Haskell.lib switches
inherit allowInconsistentDependencies;
inherit doCheck;
inherit enableDeadCodeElimination;
inherit enableLibraryProfiling;
inherit enableExecutableProfiling;
inherit enableSharedLibraries;
inherit enableStaticLibraries;
inherit enableSharedExecutables;
inherit enableSeparateBinOutput;
inherit doBenchmark;
inherit doCoverage;
inherit doHaddock;
configureFlags =
pkgs.stdenv.lib.optional doTracing "--flags=tracing"
++ pkgs.stdenv.lib.optional doOptimize "--flags=optimize"
++ pkgs.stdenv.lib.optional doStrict "--ghc-options=-Werror";
passthru = {
nixpkgs = pkgs;
inherit haskellPackages;
};
});
returnShellEnv = false;
};
composedPackage = pkgs.lib.foldr (funcOnSwitchAppliesFunction) package listOfSetsOfSwitchExtend;
in composedPackage