Skip to content

Commit 07b0c71

Browse files
iohk-bors[bot]jbgi
andauthored
Merge #4868
4868: Nix improvements backports for 1.35 r=disassembler a=jbgi Co-authored-by: Jean-Baptiste Giraudeau <[email protected]>
2 parents c617191 + c8c825b commit 07b0c71

File tree

10 files changed

+730
-289
lines changed

10 files changed

+730
-289
lines changed

flake.lock

Lines changed: 450 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 183 additions & 195 deletions
Large diffs are not rendered by default.

nix/README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
# Nix dependencies
22

3-
The nix build use the new flake format to manage dependencies. A flake-compatible nix command is provided from within `nix-shell`. To add flake support to your native nix setup please see https://nixos.wiki/wiki/Flakes.
3+
The nix build use the new flake format to manage dependencies. To add flake support to your native nix setup please see https://nixos.wiki/wiki/Flakes.
44

55
Cardano-node nix build depends primarily on [haskell.nix](https://github.com/input-output-hk/haskell.nix) and secondarily, for some utilities, on [iohk-nix](https://github.com/input-output-hk/iohk-nix/).
66

7-
Both can be updated from within a cardano-node `nix-shell` with:
7+
Both can be updated with:
88

99
```
1010
nix flake lock --update-input haskellNix
1111
nix flake lock --update-input iohkNix
1212
```
13-
14-
Or from outside the `nix-shell` with the scripts:
15-
16-
```
17-
./nix/update-haskellNix.sh
18-
./nix/update-iohkNix.sh
19-
```

nix/haskell.nix

Lines changed: 86 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
# Builds Haskell packages with Haskell.nix
33
############################################################################
44
{ haskell-nix
5-
, # Version info (git revision)
6-
gitrev
7-
, inputMap
5+
, incl
86
}:
97
let
108

@@ -18,34 +16,8 @@ let
1816
, buildProject
1917
, ...
2018
}: {
21-
inherit inputMap;
2219
name = "cardano-node";
23-
# We clean-up src to avoid rebuild for unrelated changes for tests that use $CARDANO_NODE_SRC:
24-
src =
25-
let
26-
src = haskellLib.cleanSourceWith {
27-
src = ../.;
28-
name = "cardano-node-src";
29-
filter = path: type:
30-
let
31-
relPath = lib.removePrefix "${src.origSrcSubDir}/" path;
32-
in
33-
# excludes top-level directories not part of cabal project (or used by tests):
34-
(type != "directory"
35-
|| (builtins.match ".*/.*" relPath != null)
36-
|| (!(lib.elem relPath [
37-
"nix"
38-
"doc"
39-
"ci"
40-
])
41-
&& !(lib.hasPrefix "." relPath)))
42-
# exclude ".gitignore" files
43-
&& !(lib.hasSuffix ".gitignore" relPath)
44-
# only keep cabal.project from files at root:
45-
&& (type == "directory" || builtins.match ".*/.*" relPath != null || (relPath == "cabal.project"));
46-
};
47-
in
48-
src;
20+
src = ../.;
4921
compiler-nix-name = "ghc8107";
5022
cabalProjectLocal = ''
5123
allow-newer: terminfo:base
@@ -122,45 +94,88 @@ let
12294
})
12395
projectPackagesExes;
12496
})
125-
({ pkgs, config, ... }: {
126-
# Packages we wish to ignore version bounds of.
127-
# This is similar to jailbreakCabal, however it
128-
# does not require any messing with cabal files.
129-
packages.katip.doExactConfig = true;
130-
# split data output for ekg to reduce closure size
131-
packages.ekg.components.library.enableSeparateDataOutput = true;
132-
# cardano-cli-test depends on cardano-cli
133-
# TODO: do not depend on the whole `src` just to access a few files.
134-
packages.cardano-cli.preCheck = "
135-
export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}
136-
export CARDANO_NODE_SRC=${src}
137-
";
138-
packages.cardano-node-chairman.components.tests.chairman-tests.build-tools =
139-
lib.mkForce [
140-
pkgs.lsof
141-
config.hsPkgs.cardano-node.components.exes.cardano-node
142-
config.hsPkgs.cardano-cli.components.exes.cardano-cli
143-
config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman
144-
];
145-
# cardano-node-chairman depends on cardano-node and cardano-cli
146-
# TODO: do not depend on the whole `src` just to access a few files.
147-
packages.cardano-node-chairman.preCheck = "
148-
export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}
149-
export CARDANO_NODE=${config.hsPkgs.cardano-node.components.exes.cardano-node}/bin/cardano-node${pkgs.stdenv.hostPlatform.extensions.executable}
150-
export CARDANO_NODE_CHAIRMAN=${config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman}/bin/cardano-node-chairman${pkgs.stdenv.hostPlatform.extensions.executable}
151-
export CARDANO_NODE_SRC=${src}
152-
";
153-
# cardano-testnet needs access to the git repository source
154-
# TODO: do not depend on the whole `src` just to access a few files.
155-
packages.cardano-testnet.preCheck = "
156-
export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}
157-
export CARDANO_NODE=${config.hsPkgs.cardano-node.components.exes.cardano-node}/bin/cardano-node${pkgs.stdenv.hostPlatform.extensions.executable}
158-
export CARDANO_SUBMIT_API=${config.hsPkgs.cardano-submit-api.components.exes.cardano-submit-api}/bin/cardano-submit-api${pkgs.stdenv.hostPlatform.extensions.executable}
159-
${lib.optionalString (!pkgs.stdenv.hostPlatform.isWindows) ''
160-
''}
161-
export CARDANO_NODE_SRC=${src}
162-
";
163-
})
97+
({ pkgs, config, ... }:
98+
let
99+
exportCliPath = "export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}";
100+
exportNodePath = "export CARDANO_NODE=${config.hsPkgs.cardano-node.components.exes.cardano-node}/bin/cardano-node${pkgs.stdenv.hostPlatform.extensions.executable}";
101+
mainnetConfigFiles = [
102+
"configuration/cardano/mainnet-config.yaml"
103+
"configuration/cardano/mainnet-config.json"
104+
"configuration/cardano/mainnet-byron-genesis.json"
105+
"configuration/cardano/mainnet-shelley-genesis.json"
106+
"configuration/cardano/mainnet-alonzo-genesis.json"
107+
];
108+
in
109+
{
110+
# Packages we wish to ignore version bounds of.
111+
# This is similar to jailbreakCabal, however it
112+
# does not require any messing with cabal files.
113+
packages.katip.doExactConfig = true;
114+
# split data output for ekg to reduce closure size
115+
packages.ekg.components.library.enableSeparateDataOutput = true;
116+
# cardano-cli tests depend on cardano-cli and some config files:
117+
packages.cardano-cli.components.tests.cardano-cli-golden.preCheck =
118+
let
119+
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
120+
filteredProjectBase = incl ../. [
121+
"scripts/plutus/scripts/v1/custom-guess-42-datum-42.plutus"
122+
];
123+
in
124+
''
125+
${exportCliPath}
126+
export CARDANO_NODE_SRC=${filteredProjectBase}
127+
'';
128+
packages.cardano-cli.components.tests.cardano-cli-test.preCheck =
129+
let
130+
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
131+
filteredProjectBase = incl ../. mainnetConfigFiles;
132+
in
133+
''
134+
${exportCliPath}
135+
export CARDANO_NODE_SRC=${filteredProjectBase}
136+
'';
137+
packages.cardano-node-chairman.components.tests.chairman-tests.build-tools =
138+
lib.mkForce [
139+
pkgs.lsof
140+
config.hsPkgs.cardano-node.components.exes.cardano-node
141+
config.hsPkgs.cardano-cli.components.exes.cardano-cli
142+
config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman
143+
];
144+
# cardano-node-chairman depends on cardano-node and cardano-cli, and some config files
145+
packages.cardano-node-chairman.preCheck =
146+
let
147+
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
148+
filteredProjectBase = incl ../. [
149+
"configuration/chairman"
150+
"configuration/defaults/byron-mainnet"
151+
"cardano-cli/test/data/golden/alonzo/genesis.alonzo.spec.json"
152+
"scripts/protocol-params.json"
153+
];
154+
in
155+
''
156+
${exportCliPath}
157+
${exportNodePath}
158+
export CARDANO_NODE_CHAIRMAN=${config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman}/bin/cardano-node-chairman${pkgs.stdenv.hostPlatform.extensions.executable}
159+
export CARDANO_NODE_SRC=${filteredProjectBase}
160+
'';
161+
# cardano-testnet depends on cardano-node, cardano-cli, cardano-submit-api and some config files
162+
packages.cardano-testnet.preCheck =
163+
let
164+
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
165+
filteredProjectBase = incl ../. (mainnetConfigFiles ++ [
166+
"configuration/cardano/mainnet-topology.json"
167+
"configuration/defaults/byron-mainnet"
168+
"cardano-cli/test/data/golden/alonzo/genesis.alonzo.spec.json"
169+
"scripts/babbage/alonzo-babbage-test-genesis.json"
170+
]);
171+
in
172+
''
173+
${exportCliPath}
174+
${exportNodePath}
175+
export CARDANO_SUBMIT_API=${config.hsPkgs.cardano-submit-api.components.exes.cardano-submit-api}/bin/cardano-submit-api${pkgs.stdenv.hostPlatform.extensions.executable}
176+
export CARDANO_NODE_SRC=${filteredProjectBase}
177+
'';
178+
})
164179
({ pkgs, ... }: lib.mkIf (!pkgs.stdenv.hostPlatform.isDarwin) {
165180
# Needed for profiled builds to fix an issue loading recursion-schemes part of makeBaseFunctor
166181
# that is missing from the `_p` output. See https://gitlab.haskell.org/ghc/ghc/-/issues/18320
@@ -206,7 +221,8 @@ let
206221
});
207222
in project.appendOverlays (with haskellLib.projectOverlays; [
208223
projectComponents
209-
(final: prev: let inherit (final.pkgs) lib; in {
224+
(final: prev:
225+
let inherit (final.pkgs) lib gitrev; in {
210226
profiled = final.appendModule {
211227
modules = [{
212228
enableLibraryProfiling = true;

nix/update-haskellNix.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

nix/update-iohkNix.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

nix/workbench/analyse.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
pkgs.runCommand "workbench-run-analysis-${profileNix.name}"
88
{ requiredSystemFeatures = [ "benchmark" ];
99
nativeBuildInputs = with pkgs.haskellPackages; with pkgs;
10-
[ bash coreutils gnused jq moreutils nixWrapped workbench.workbench ];
10+
[ bash coreutils gnused jq moreutils nix workbench.workbench ];
1111
}
1212
''
1313
echo "analysing run: ${run}"

nix/workbench/backend/supervisor-run.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ in
8383
gnused
8484
jq
8585
moreutils
86-
nixWrapped
86+
nix
8787
pstree
8888
python3Packages.supervisor
8989
workbench.workbench
@@ -108,7 +108,7 @@ in
108108
--genesis-cache-entry ${genesis}
109109
--batch-name smoke-test
110110
--base-port ${toString basePort}
111-
--node-source ${pkgs.cardanoNodeProject.args.src.origSrc}
111+
--node-source ${pkgs.cardanoNodeProject.args.src}
112112
--node-rev ${cardano-node-rev}
113113
--cache-dir ./cache
114114
)

nix/workbench/supervisor-run.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ let
8989
gnused
9090
jq
9191
moreutils
92-
nixWrapped
92+
nix
9393
pstree
9494
python3Packages.supervisor
9595
workbench.workbench

shell.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ let
7474
haskellBuildUtils
7575
pkgs.graphviz
7676
weeder
77-
nixWrapped
77+
nix
7878
pkgconfig
7979
profiteur
8080
profiterole
@@ -132,7 +132,7 @@ let
132132
packages = _: [];
133133

134134
nativeBuildInputs = with cardanoNodePackages; [
135-
nixWrapped
135+
nix
136136
cardano-cli
137137
bech32
138138
cardano-ping
@@ -149,6 +149,9 @@ let
149149
pkgs.time
150150
];
151151

152+
# build tools for all hasPkgs not needed (would include duplicates for cardano-cli, cardano-node, etc.)
153+
allToolDeps = false;
154+
152155
shellHook = ''
153156
echo "DevOps Tools" \
154157
| ${figlet}/bin/figlet -f banner -c \

0 commit comments

Comments
 (0)