forked from IntersectMBO/cardano-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
91 lines (77 loc) · 3.03 KB
/
default.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
91
{ system ? builtins.currentSystem
, crossSystem ? null
# allows to cutomize haskellNix (ghc and profiling, see ./nix/haskell.nix)
, config ? {}
# override scripts with custom configuration
, customConfig ? {}
# allows to override dependencies of the project without modifications,
# eg. to test build against local checkout of nixpkgs and iohk-nix:
# nix build -f default.nix cardano-node --arg sourcesOverride '{
# iohk-nix = ../iohk-nix;
# }'
, sourcesOverride ? {}
# pinned version of nixpkgs augmented with overlays (iohk-nix and our packages).
, pkgs ? import ./nix/default.nix { inherit system crossSystem config sourcesOverride gitrev; }
# Git sha1 hash, to be passed when not building from a git work tree.
, gitrev ? null
}:
with pkgs; with commonLib;
let
haskellPackages = recRecurseIntoAttrs
# the Haskell.nix package set, reduced to local packages.
(selectProjectPackages cardanoNodeHaskellPackages);
scripts = callPackage ./nix/scripts.nix { inherit customConfig; };
# NixOS tests run a proxy and validate it listens
nixosTests = recRecurseIntoAttrs (import ./nix/nixos/tests {
inherit pkgs;
});
dockerImage = let
defaultConfig = rec {
stateDir = "/data";
dbPrefix = "db";
socketPath = "/ipc/node.socket";
};
customConfig' = defaultConfig // customConfig;
in pkgs.callPackage ./nix/docker.nix {
inherit (packages) cardano-node cardano-cli;
scripts = callPackage ./nix/scripts.nix { customConfig = customConfig'; };
};
rewrite-static = _: p: if (pkgs.stdenv.hostPlatform.isDarwin) then
pkgs.runCommandCC p.name {
nativeBuildInputs = [ pkgs.haskellBuildUtils.package pkgs.buildPackages.binutils pkgs.buildPackages.nix ];
} ''
cp -R ${p} $out
chmod -R +w $out
rewrite-libs $out/bin $out/bin/*
'' else if (pkgs.stdenv.hostPlatform.isMusl) then
pkgs.runCommandCC p.name { } ''
cp -R ${p} $out
chmod -R +w $out
$STRIP $out/bin/*
'' else p;
packages = {
inherit haskellPackages cardano-node cardano-cli db-converter cardano-ping
scripts nixosTests environments dockerImage mkCluster bech32;
# so that eval time gc roots are cached (nix-tools stuff)
inherit (cardanoNodeHaskellPackages) roots;
inherit (haskellPackages.cardano-node.identifier) version;
inherit (haskellPackages.cardano-node.project) plan-nix;
exes = mapAttrsRecursiveCond (as: !(isDerivation as)) rewrite-static (collectComponents' "exes" haskellPackages);
# `tests` are the test suites which have been built.
tests = collectComponents' "tests" haskellPackages;
# `benchmarks` (only built, not run).
benchmarks = collectComponents' "benchmarks" haskellPackages;
checks = recurseIntoAttrs {
# `checks.tests` collect results of executing the tests:
tests = collectChecks haskellPackages;
hlint = callPackage iohkNix.tests.hlint {
src = ./. ;
};
};
profiles = (mkCluster customConfig).profilesJSON;
shell = import ./shell.nix {
inherit pkgs;
withHoogle = true;
};
};
in packages