forked from IntersectMBO/plutus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.nix
90 lines (85 loc) · 3.98 KB
/
ci.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
# 'supportedSystems' restricts the set of systems that we will evaluate for. Useful when you're evaluting
# on a machine with e.g. no way to build the Darwin IFDs you need!
supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
# This will be used by the packages that get the git revision in lieu of actually trying to find it,
# which doesn't work in all situations. Set to null to get it from git.
, rev ? "fake"
}:
let
inherit (import ./nix/lib/ci.nix) dimension platformFilterGeneric filterAttrsOnlyRecursive filterSystems;
sources = import ./nix/sources.nix;
# limit supportedSystems to what the CI can actually build
# currently that is linux and darwin.
systems = filterSystems supportedSystems;
# Collects haskell derivations and builds an attrset:
#
# { library = { ... }
# , tests = { ... }
# , benchmarks = { ... }
# , exes = { ... }
# , checks = { ... }
# }
# Where each attribute contains an attribute set
# with all haskell components of that type
mkHaskellDimension = pkgs: haskellProjects:
let
# retrieve all checks from a Haskell package
collectChecks = _: ps: pkgs.haskell-nix.haskellLib.collectChecks' ps;
# retrieve all components of a Haskell package
collectComponents = type: ps: pkgs.haskell-nix.haskellLib.collectComponents' type ps;
# Given a component type and the retrieve function, retrieve components from haskell packages
select = type: selector: (selector type) haskellProjects;
# { component-type : retriever-fn }
attrs = {
"library" = collectComponents;
"tests" = collectComponents;
"benchmarks" = collectComponents;
"exes" = collectComponents;
"checks" = collectChecks;
};
in
dimension "Haskell component" attrs select;
# Collects all project derivations to build grouped by system:
#
# { linux = { ... }
# , darwin = { ... }
# }
mkSystemDimension = systems:
let
# given a system ("x86_64-linux") return an attrset of derivations to build
select = _: system:
let
packages = import ./default.nix { inherit system rev; checkMaterialization = true; };
pkgs = packages.pkgs;
plutus = packages.plutus;
isBuildable = platformFilterGeneric pkgs system;
in
filterAttrsOnlyRecursive (_: drv: isBuildable drv) {
# build relevant top level attributes from default.nix
inherit (packages) docs tests plutus-playground marlowe-playground plutus-pab marlowe-symbolic-lambda marlowe-playground-lambda plutus-playground-lambda;
# The haskell.nix IFD roots for the Haskell project. We include these so they won't be GCd and will be in the
# cache for users
inherit (plutus.haskell.project) roots;
# Should be in roots, see https://github.com/input-output-hk/haskell.nix/issues/967
inherit (pkgs.haskell-nix) internal-nix-tools internal-cabal-install;
# Build the shell expression to be sure it works on all platforms
#
# The shell should never depend on any of our Haskell packages, which can
# sometimes happen by accident. In practice, everything depends transitively
# on 'plutus-core', so this does the job.
# FIXME: this should simply be set on the main shell derivation, but this breaks
# lorri: https://github.com/target/lorri/issues/489. In the mean time, we set it
# only on the CI version, so that we still catch it, but lorri doesn't see it.
shell = (import ./shell.nix { inherit packages; }).overrideAttrs (attrs: attrs // {
disallowedRequisites = [ plutus.haskell.packages.plutus-core.components.library ];
});
# build deployment tools
inherit (plutus) thorp;
# build all haskell packages and tests
haskell = pkgs.recurseIntoAttrs (mkHaskellDimension pkgs plutus.haskell.projectPackages);
};
in
dimension "System" systems select;
in
mkSystemDimension systems