termonad-3.1.0.0: .nix-helpers/nixpkgs.nix
# This file pins the version of nixpkgs to a known good version. The nixpkgs is
# imported with an overlay adding Termonad. It is imported from various other
# files.
{ # String representing a GHC version to use. Normally something like
# "ghc865". If null, then use a known-working GHC version.
compiler ? null
, # A path to nixpkgs. This will be imported. If null, use a known-working
# nixpkgs version.
nixpkgs ? null
, # Additional overlays to apply when importing nixpkgs.
additionalOverlays ? []
, # Build all the examples bundled with termonad. Normally this is only used
# in CI for testing that the examples all still compile.
buildExamples ? false
}:
let
nixpkgsSrc =
if isNull nixpkgs
then
builtins.fetchTarball {
# Recent version of nixpkgs master as of 2020-03-01.
url = "https://github.com/NixOS/nixpkgs/archive/4f36e9f9a33da034327188ddebc3aecb3633e4d7.tar.gz";
sha256 = "sha256:0aa3aldp6m962hx0qzkizkwvamwv2c4yijk6g515dx7h7f5xrary";
}
else nixpkgs;
compilerVersion = if isNull compiler then "ghc882" else compiler;
# An overlay that adds termonad to all haskell package sets.
haskellPackagesOverlay = self: super: {
haskell = super.haskell // {
packageOverrides = hself: hsuper:
super.haskell.packageOverrides hself hsuper // {
termonad =
let
filesToIgnore = [
".git"
".nix-helpers"
"result"
".stack-work"
".travis.yml"
];
src =
builtins.filterSource
(path: type: with self.stdenv.lib;
! elem (baseNameOf path) filesToIgnore &&
! any (flip hasPrefix (baseNameOf path)) [ "dist" ".ghc" ]
)
./..;
extraCabal2nixOptions =
self.lib.optionalString buildExamples "-fbuildexamples";
termonadDrv =
hself.callCabal2nixWithOptions
"termonad"
src
extraCabal2nixOptions
{
inherit (self) gtk3;
libpcre2 = self.pcre2;
vte_291 = self.vte;
};
in
termonadDrv;
};
};
# A Haskell package set where we know the GHC version works to compile
# Termonad. This is basically just a shortcut so that other Nix files
# don't need to figure out the correct compiler version to use when it is
# not given by the user.
termonadKnownWorkingHaskellPkgSet = self.haskell.packages.${compilerVersion};
};
in import nixpkgsSrc { overlays = [ haskellPackagesOverlay ] ++ additionalOverlays; }