1
1
mirror of https://github.com/coot/free-category.git synced 2024-11-22 16:22:05 +03:00

Use haskell.nix

Only compile with ghc: 8.10.1, 8.8.3 and 8.6.5; drop older versions.
This commit is contained in:
Marcin Szamotulski 2020-07-21 18:23:15 +02:00
parent 611af1ae70
commit 1ad08548dd
18 changed files with 234 additions and 327 deletions

View File

@ -22,6 +22,7 @@ commands:
- run:
name: "cachix"
command: |
cachix use iohk
cachix use free-algebras
- checkout
cachix-push:
@ -35,15 +36,28 @@ commands:
name: "cachix push"
command: cachix push free-algebras << parameters.o >>
jobs:
GHC881:
GHC8101:
<<: *defaults
steps:
- setup
- run:
name: "GHC 881"
name: "GHC 8.10.1"
command: |
nix-build release.nix -A free-category --argstr compiler ghc881 -o result-fc
nix-build release.nix -A examples --argstr compiler ghc881 -o result-ex
nix-build -A free-category.components.all --argstr compiler ghc8101 -o result-fc
nix-build -A examples.components.all --argstr compiler ghc8101 -o result-ex
- cachix-push:
o: "./result-fc"
- cachix-push:
o: "./result-ex"
GHC883:
<<: *defaults
steps:
- setup
- run:
name: "GHC 8.8.3"
command: |
nix-build -A free-category.components.all --argstr compiler ghc883 -o result-fc
nix-build -A examples.components.all --argstr compiler ghc883 -o result-ex
- cachix-push:
o: "./result-fc"
- cachix-push:
@ -53,50 +67,10 @@ jobs:
steps:
- setup
- run:
name: "GHC 865"
name: "GHC 8.6.5"
command: |
nix-build release.nix -A free-category --argstr compiler ghc865 -o result-fc
nix-build release.nix -A examples --argstr compiler ghc865 -o result-ex
- cachix-push:
o: result-fc
- cachix-push:
o: result-ex
GHC844:
<<: *defaults
steps:
- setup
- run:
name: "GHC 844"
command: |
nix-build release.nix -A free-category -o result-fc --argstr compiler ghc844
nix-build release.nix -A examples -o result-ex --argstr compiler ghc844
- cachix-push:
o: result-fc
- cachix-push:
o: result-ex
GHC822:
<<: *defaults
steps:
- setup
- run:
name: "GHC 822"
command: |
nix-build release.nix -A free-category -o result-fc --argstr compiler ghc822
nix-build release.nix -A examples -o result-ex --argstr compiler ghc822
- cachix-push:
o: result-fc
- cachix-push:
o: result-ex
GHC802:
<<: *defaults
steps:
- setup
- run:
name: "GHC 802"
command: |
nix-build release.nix -A free-category --argstr compiler ghc802 -o result-fc
nix-build release.nix -A examples --argstr compiler ghc802 -o result-ex
nix-build -A free-category.components.all --argstr compiler ghc865 -o result-fc
nix-build -A examples.components.all --argstr compiler ghc865 -o result-ex
- cachix-push:
o: result-fc
- cachix-push:
@ -105,9 +79,7 @@ jobs:
workflows:
build:
jobs:
- GHC881
- GHC8101
- GHC883
- GHC865
- GHC844
- GHC822
- GHC802

View File

@ -1,2 +1,3 @@
packages: .
./examples
index-state: 2020-05-15T00:00:00Z
packages: free-category.cabal
examples/examples.cabal

View File

@ -1,50 +1,41 @@
{ compiler ? "ghc865"
, haddock ? true
, test ? true
, benchmarks ? false
, dev ? true
}:
with builtins;
let
nixpkgs = import ./nix/nixpkgs.nix { inherit compiler; };
let compiler-nix-name = compiler;
pkgs = nixpkgs.haskell.packages;
lib = nixpkgs.haskell.lib;
callCabal2nix = nixpkgs.haskell.packages.${compiler}.callCabal2nix;
sources = import ./nix/sources.nix {};
iohkNix = import sources.iohk-nix {};
haskellNix = import sources."haskell.nix" {};
nixpkgs = iohkNix.nixpkgs;
haskell-nix = haskellNix.pkgs.haskell-nix;
doHaddock = if haddock
then lib.doHaddock
else lib.dontHaddock;
doTest = if test
then lib.doCheck
else lib.dontCheck;
doBench = if benchmarks
then lib.doBenchmark
else nixpkgs.lib.id;
doDev = if dev
then drv: lib.appendConfigureFlag drv "--ghc-option -Werror"
else nixpkgs.lib.id;
noInlineRuleShadowing = if compiler == "ghc802"
then drv: lib.appendConfigureFlag drv "--ghc-option -Wno-inline-rule-shadowing"
else nixpkgs.lib.id;
docNoSeprateOutput = drv: lib.overrideCabal drv (drv: { enableSeparateDocOutput = false; });
srcFilter = src: path: type:
let relPath = nixpkgs.lib.removePrefix (toString src + "/") (toString path);
in
nixpkgs.lib.hasPrefix "src" relPath
|| nixpkgs.lib.hasPrefix "test" relPath
|| nixpkgs.lib.hasPrefix "bench" relPath
|| nixpkgs.lib.any
(a: a == relPath)
[ "Setup.hs" "cabal.project" "ChangeLog.md" "free-category.cabal" "LICENSE"];
# package set
pkgs = import nixpkgs
{ config = haskellNix.config;
overlays = [ (_: _: { inherit freeCategoryPackages; }) ];
};
lib = pkgs.lib;
free-category = noInlineRuleShadowing(docNoSeprateOutput(doDev(doHaddock(doTest(doBench(
lib.overrideCabal (callCabal2nix "free-category" ./. {})
(drv: {src = nixpkgs.lib.cleanSourceWith { filter = srcFilter drv.src; src = drv.src; };})
))))));
examples = docNoSeprateOutput(doDev(doHaddock(doTest(doBench(
lib.overrideCabal (callCabal2nix "examples" ./examples { inherit free-category; })
(drv: {src = nixpkgs.lib.sourceFilesBySuffices drv.src [ ".hs" "LICENSE" "ChangeLog.md" "examples.cabal" ];})
)))));
# 'cleanGit' cleans a source directory based on the files known by git
src = haskell-nix.haskellLib.cleanGit {
name = "free-algebras";
src = ./.;
};
in { inherit free-category examples; }
# unmodified packages
projectPackages = lib.attrNames
(haskell-nix.haskellLib.selectProjectPackages
(haskell-nix.cabalProject { inherit src compiler-nix-name; }));
# set GHC options
freeCategoryPackages = haskell-nix.cabalProject {
inherit src compiler-nix-name;
modules =
[
{ packages =
lib.genAttrs
projectPackages
(name: { configureFlags = [ "--ghc-option=-Werror" ]; });
}
];
};
in pkgs.freeCategoryPackages

View File

@ -1,3 +1,4 @@
cabal-version: >= 2.0
name: free-category
version: 0.0.4.1
synopsis: efficient data types for free categories and arrows
@ -15,7 +16,6 @@ copyright: (c) 2018-2019 Marcin Szamotulski
license: MPL-2.0
license-file: LICENSE
build-type: Simple
cabal-version: >= 1.10
extra-source-files:
ChangeLog.md
README.md

View File

@ -1,12 +0,0 @@
{ mkDerivation, base, stdenv }:
mkDerivation {
pname = "ansi-terminal";
version = "0.6.3.1";
sha256 = "458f98e0c9217897f0ff07f730cfc3ed380089936fb31942aec31bb336608095";
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [ base ];
homepage = "https://github.com/feuerbach/ansi-terminal";
description = "Simple ANSI terminal support, with Windows compatibility";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,15 +0,0 @@
{ mkDerivation, base, HUnit, stdenv, stm, test-framework
, test-framework-hunit
}:
mkDerivation {
pname = "async";
version = "2.1.1.1";
sha256 = "cd83e471466ea6885b2e8fb60f452db3ac3fdf3ea2d6370aa1e071ebc37544e2";
libraryHaskellDepends = [ base stm ];
testHaskellDepends = [
base HUnit test-framework test-framework-hunit
];
homepage = "https://github.com/simonmar/async";
description = "Run IO operations asynchronously and wait for their results";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,10 +0,0 @@
{ mkDerivation, base, Cabal, directory, filepath, stdenv }:
mkDerivation {
pname = "cabal-doctest";
version = "1.0.7";
sha256 = "1080ed5f7eca48621853178d701dbee209698eb357957e00a56da6d635a7adec";
libraryHaskellDepends = [ base Cabal directory filepath ];
homepage = "https://github.com/phadej/cabal-doctest";
description = "A Setup.hs helper for doctests running";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,14 +0,0 @@
{ mkDerivation, ansi-terminal, async, base, directory, exceptions
, process, stdenv, stm, terminal-size, text, transformers, unix
}:
mkDerivation {
pname = "concurrent-output";
version = "1.9.2";
sha256 = "3bc2423adb5cdae14278e718b1335363cc21cd74b370d47dc4e07d2287b2d9f3";
libraryHaskellDepends = [
ansi-terminal async base directory exceptions process stm
terminal-size text transformers unix
];
description = "Ungarble output from several threads or commands";
license = stdenv.lib.licenses.bsd2;
}

View File

@ -1,21 +0,0 @@
{ mkDerivation, base, mtl, QuickCheck, stdenv, stm
, template-haskell, test-framework, test-framework-quickcheck2
, transformers, transformers-compat
}:
mkDerivation {
pname = "exceptions";
version = "0.8.3";
sha256 = "4d6ad97e8e3d5dc6ce9ae68a469dc2fd3f66e9d312bc6faa7ab162eddcef87be";
revision = "5";
editedCabalFile = "1kfgp41i6mfz9gjczp3flvqxfhnznd81rwldv8j05807n6mnqqii";
libraryHaskellDepends = [
base mtl stm template-haskell transformers transformers-compat
];
testHaskellDepends = [
base mtl QuickCheck stm template-haskell test-framework
test-framework-quickcheck2 transformers transformers-compat
];
homepage = "http://github.com/ekmett/exceptions/";
description = "Extensible optionally-pure exceptions";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,19 +0,0 @@
{ mkDerivation, base, containers, data-fix, dlist, free, groups
, hedgehog, kan-extensions, mtl, stdenv, transformers
}:
mkDerivation {
pname = "free-algebras";
version = "0.0.8.0";
sha256 = "47eafb41c60ca509de7078f5d283bd88cf7e1ff81ddb49965d67a9e0e9969b43";
libraryHaskellDepends = [
base containers data-fix dlist free groups kan-extensions mtl
transformers
];
testHaskellDepends = [
base containers data-fix dlist free groups hedgehog kan-extensions
mtl transformers
];
homepage = "https://github.com/coot/free-algebras#readme";
description = "Free algebras in Haskell";
license = stdenv.lib.licenses.mpl20;
}

View File

@ -1,19 +0,0 @@
{ mkDerivation, array, base, containers, directory, filepath
, ghc-prim, happy, mtl, pretty, pretty-show, smallcheck, stdenv
, tasty, tasty-golden, tasty-smallcheck
}:
mkDerivation {
pname = "haskell-src-exts";
version = "1.21.1";
sha256 = "2ec911614325f1e5eef7e5bef15c08b8265931d69da3ce566af109d486453e60";
libraryHaskellDepends = [ array base ghc-prim pretty ];
libraryToolDepends = [ happy ];
testHaskellDepends = [
base containers directory filepath mtl pretty-show smallcheck tasty
tasty-golden tasty-smallcheck
];
doCheck = false;
homepage = "https://github.com/haskell-suite/haskell-src-exts";
description = "Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,26 +0,0 @@
{ mkDerivation, ansi-terminal, async, base, bytestring
, concurrent-output, containers, directory, exceptions, fail
, lifted-async, mmorph, monad-control, mtl, pretty-show, primitive
, random, resourcet, semigroups, stdenv, stm, template-haskell
, text, time, transformers, transformers-base, wl-pprint-annotated
}:
mkDerivation {
pname = "hedgehog";
version = "1.0.1";
sha256 = "202ea01fe1f30890307bd8c1ceaa0d24f988472e8371237271636abbf08487e1";
revision = "1";
editedCabalFile = "0dq3ry7py2wsiwxar11zbvm3xmifm92nx4bh61lqxzmpwyyiwnxn";
libraryHaskellDepends = [
ansi-terminal async base bytestring concurrent-output containers
directory exceptions fail lifted-async mmorph monad-control mtl
pretty-show primitive random resourcet semigroups stm
template-haskell text time transformers transformers-base
wl-pprint-annotated
];
testHaskellDepends = [
base containers mmorph mtl pretty-show semigroups text transformers
];
homepage = "https://hedgehog.qa";
description = "Release with confidence";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,18 +0,0 @@
{ mkDerivation, base, containers, filepath, mtl, parsec, stdenv
, test-framework, test-framework-hunit
}:
mkDerivation {
pname = "hoopl";
version = "3.10.2.2";
sha256 = "097b1316d5f1c8ffe71133223209eb2b095fe13f43dc01d1fe43fd8a545a2b97";
revision = "2";
editedCabalFile = "0j6pz4jzhvviyrhhn1j22ikmjvzrg60nzvq26lbpkcb6y4q6rlyx";
libraryHaskellDepends = [ base containers ];
testHaskellDepends = [
base containers filepath mtl parsec test-framework
test-framework-hunit
];
homepage = "https://github.com/haskell/hoopl";
description = "A library to support dataflow analysis and optimization";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,20 +0,0 @@
{ mkDerivation, async, base, constraints, criterion, deepseq, HUnit
, lifted-base, monad-control, mtl, stdenv, tasty, tasty-hunit
, tasty-th, transformers-base
}:
mkDerivation {
pname = "lifted-async";
version = "0.9.3.3";
sha256 = "ae37d9cab3dd21aa65e4722c5268585d2d555fea1e8870920e7e567160240dbf";
libraryHaskellDepends = [
async base constraints lifted-base monad-control transformers-base
];
testHaskellDepends = [
async base HUnit lifted-base monad-control mtl tasty tasty-hunit
tasty-th
];
benchmarkHaskellDepends = [ async base criterion deepseq ];
homepage = "https://github.com/maoe/lifted-async";
description = "Run lifted IO operations asynchronously and wait for their results";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,45 +0,0 @@
{ compiler ? "ghc865" }:
with builtins;
let
rev = if compiler == "ghc802"
|| compiler == "ghc822"
|| compiler == "ghc844"
then "722fcbbb80b2142583e9266efe77992f8e32ac4c"
else "a2f9bcd1328de9c043d7425e45d06fc05e0b7929";
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
config =
{ packageOverrides = super:
let self = super.pkgs;
lib = super.haskell.lib;
overrides = self: super: {
free-algebras = super.callPackage ./free-algebras.nix {};
};
in {
haskell = super.haskell // {
packages = super.haskell.packages // {
ghc881 = super.haskell.packages.ghc881.override {
overrides = self: super: overrides self super // {
cabal-doctest = super.callPackage ./cabal-doctest-1.0.7.nix {};
haskell-src-exts = super.callPackage ./haskell-src-exts-1.21.1.nix {};
hedgehog = super.callPackage ./hedgehog-1.0.1.nix {};
};
};
ghc865 = super.haskell.packages.ghc865.override { inherit overrides; };
ghc844 = super.haskell.packages.ghc844.override { inherit overrides; };
ghc822 = super.haskell.packages.ghc822.override { inherit overrides; };
ghc802 = super.haskell.packages.ghc802.override {
overrides = self: super: overrides self super // {
ansi-terminal = super.callPackage ./ansi-terminal-0.6.3.1.nix {};
async = super.callPackage ./async-2.1.1.1.nix {};
lifted-async = super.callPackage ./lifted-async-0.9.3.3.nix {};
exceptions = super.callPackage ./exceptions-0.8.3.nix {};
stm = super.callPackage ./stm-2.4.5.1.nix {};
concurrent-output = super.callPackage ./concurrent-output-1.9.2.nix {};
};
};
};
};
};
};
nixpkgs = import (fetchTarball { inherit url; }) { inherit config; };
in nixpkgs

38
nix/sources.json Normal file
View File

@ -0,0 +1,38 @@
{
"haskell.nix": {
"branch": "master",
"description": "Alternative Haskell Infrastructure for Nixpkgs",
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "32baaac4d7858ae3349c1f6d1452371f998c7f49",
"sha256": "0g0jh0jwips3qyxs7rb1d4qvqs6rralnq318x5x2wvy1mkzvxvlg",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/32baaac4d7858ae3349c1f6d1452371f998c7f49.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"iohk-nix": {
"branch": "master",
"description": "nix scripts shared across projects",
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "00788ac974a517846dba09bd5e095757011cb083",
"sha256": "0lxffzd31a359d7j9q0vwaj6d5lq0ka5df6g0g30rm91sw7jkpnj",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/00788ac974a517846dba09bd5e095757011cb083.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "372f96bff217a7a019de27667d04118cffa9841b",
"sha256": "1l0z6162zw60pdcdj03aq64qgf1vyzmf24i9pxca64i4sprl1b7p",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/372f96bff217a7a019de27667d04118cffa9841b.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

134
nix/sources.nix Normal file
View File

@ -0,0 +1,134 @@
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: spec:
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; }
else
pkgs.fetchurl { inherit (spec) url sha256; };
fetch_tarball = pkgs: spec:
if spec.builtin or true then
builtins_fetchTarball { inherit (spec) url sha256; }
else
pkgs.fetchzip { inherit (spec) url sha256; };
fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
fetch_builtin-tarball = spec:
builtins.trace
''
WARNING:
The niv type "builtin-tarball" will soon be deprecated. You should
instead use `builtin = true`.
$ niv modify <package> -a type=tarball -a builtin=true
''
builtins_fetchTarball { inherit (spec) url sha256; };
fetch_builtin-url = spec:
builtins.trace
''
WARNING:
The niv type "builtin-url" will soon be deprecated. You should
instead use `builtin = true`.
$ niv modify <package> -a type=file -a builtin=true
''
(builtins_fetchurl { inherit (spec) url sha256; });
#
# Various helpers
#
# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs spec
else if spec.type == "tarball" then fetch_tarball pkgs spec
else if spec.type == "git" then fetch_git spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
else if spec.type == "builtin-url" then fetch_builtin-url spec
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or (
f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);
# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball { inherit url; }
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl { inherit url; }
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = fetch config.pkgs name spec; }
) config.sources;
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? ./sources.json
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
, pkgs ? mkPkgs sources
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs;
};
in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

View File

@ -1,10 +0,0 @@
{ mkDerivation, array, base, stdenv }:
mkDerivation {
pname = "stm";
version = "2.4.5.1";
sha256 = "6cf0c280062736c9980ba1c2316587648b8e9d4e4ecc5aed16a41979c0a3a3f4";
libraryHaskellDepends = [ array base ];
homepage = "https://wiki.haskell.org/Software_transactional_memory";
description = "Software Transactional Memory";
license = stdenv.lib.licenses.bsd3;
}