This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.nix
66 lines (59 loc) · 2.42 KB
/
release.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
let
packages = import ./.;
pkgs = packages.pkgs;
haskellNix = pkgs.haskell-nix;
plutusApps = packages.plutus.plutus-apps;
wait-for = pkgs.writeScriptBin "wait-for" (builtins.fetchurl "https://raw.githubusercontent.com/eficode/wait-for/master/wait-for");
projectPackages =
haskellNix.haskellLib.selectProjectPackages packages.project.hsPkgs;
inherit (import ./nix/lib/build.nix { inherit pkgs; }) dimension;
# 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;
mkDockerImage = pkgs: package: imageName: execName:
pkgs.dockerTools.buildImage {
name = imageName;
tag = "latest";
contents = [ package pkgs.bash pkgs.busybox wait-for ];
config = { Cmd = [ "/bin/${execName}" ]; };
};
build = pkgs.recurseIntoAttrs (mkHaskellDimension pkgs projectPackages);
exes = build.exes;
pab-exec = exes.dex."dex-pab";
middleware-exec = exes.middleware."middleware-manual";
faucet-exec = exes."faucet-backend"."faucet-app";
plutus-chain-index-exec = plutusApps.haskell.packages.plutus-chain-index.components.exes."plutus-chain-index";
in
{
backend = mkDockerImage pkgs pab-exec "dex-backend" "dex-pab";
middleware = mkDockerImage pkgs middleware-exec "dex-middleware" "midleware-manual";
chain-index = mkDockerImage pkgs plutus-chain-index-exec "dex-chain-index" "plutus-chain-index";
faucet =
(import ./faucet/faucet-backend/nix/release.nix).mkDockerImage pkgs faucet-exec;
}