Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix improvements backports for 1.35 #4868

Merged
merged 4 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
451 changes: 450 additions & 1 deletion flake.lock

Large diffs are not rendered by default.

378 changes: 183 additions & 195 deletions flake.nix

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions nix/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
# Nix dependencies

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.
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.

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/).

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

```
nix flake lock --update-input haskellNix
nix flake lock --update-input iohkNix
```

Or from outside the `nix-shell` with the scripts:

```
./nix/update-haskellNix.sh
./nix/update-iohkNix.sh
```
156 changes: 86 additions & 70 deletions nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# Builds Haskell packages with Haskell.nix
############################################################################
{ haskell-nix
, # Version info (git revision)
gitrev
, inputMap
, incl
}:
let

Expand All @@ -18,34 +16,8 @@ let
, buildProject
, ...
}: {
inherit inputMap;
name = "cardano-node";
# We clean-up src to avoid rebuild for unrelated changes for tests that use $CARDANO_NODE_SRC:
src =
let
src = haskellLib.cleanSourceWith {
src = ../.;
name = "cardano-node-src";
filter = path: type:
let
relPath = lib.removePrefix "${src.origSrcSubDir}/" path;
in
# excludes top-level directories not part of cabal project (or used by tests):
(type != "directory"
|| (builtins.match ".*/.*" relPath != null)
|| (!(lib.elem relPath [
"nix"
"doc"
"ci"
])
&& !(lib.hasPrefix "." relPath)))
# exclude ".gitignore" files
&& !(lib.hasSuffix ".gitignore" relPath)
# only keep cabal.project from files at root:
&& (type == "directory" || builtins.match ".*/.*" relPath != null || (relPath == "cabal.project"));
};
in
src;
src = ../.;
compiler-nix-name = "ghc8107";
cabalProjectLocal = ''
allow-newer: terminfo:base
Expand Down Expand Up @@ -122,45 +94,88 @@ let
})
projectPackagesExes;
})
({ pkgs, config, ... }: {
# Packages we wish to ignore version bounds of.
# This is similar to jailbreakCabal, however it
# does not require any messing with cabal files.
packages.katip.doExactConfig = true;
# split data output for ekg to reduce closure size
packages.ekg.components.library.enableSeparateDataOutput = true;
# cardano-cli-test depends on cardano-cli
# TODO: do not depend on the whole `src` just to access a few files.
packages.cardano-cli.preCheck = "
export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_NODE_SRC=${src}
";
packages.cardano-node-chairman.components.tests.chairman-tests.build-tools =
lib.mkForce [
pkgs.lsof
config.hsPkgs.cardano-node.components.exes.cardano-node
config.hsPkgs.cardano-cli.components.exes.cardano-cli
config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman
];
# cardano-node-chairman depends on cardano-node and cardano-cli
# TODO: do not depend on the whole `src` just to access a few files.
packages.cardano-node-chairman.preCheck = "
export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_NODE=${config.hsPkgs.cardano-node.components.exes.cardano-node}/bin/cardano-node${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_NODE_CHAIRMAN=${config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman}/bin/cardano-node-chairman${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_NODE_SRC=${src}
";
# cardano-testnet needs access to the git repository source
# TODO: do not depend on the whole `src` just to access a few files.
packages.cardano-testnet.preCheck = "
export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_NODE=${config.hsPkgs.cardano-node.components.exes.cardano-node}/bin/cardano-node${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_SUBMIT_API=${config.hsPkgs.cardano-submit-api.components.exes.cardano-submit-api}/bin/cardano-submit-api${pkgs.stdenv.hostPlatform.extensions.executable}
${lib.optionalString (!pkgs.stdenv.hostPlatform.isWindows) ''
''}
export CARDANO_NODE_SRC=${src}
";
})
({ pkgs, config, ... }:
let
exportCliPath = "export CARDANO_CLI=${config.hsPkgs.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli${pkgs.stdenv.hostPlatform.extensions.executable}";
exportNodePath = "export CARDANO_NODE=${config.hsPkgs.cardano-node.components.exes.cardano-node}/bin/cardano-node${pkgs.stdenv.hostPlatform.extensions.executable}";
mainnetConfigFiles = [
"configuration/cardano/mainnet-config.yaml"
"configuration/cardano/mainnet-config.json"
"configuration/cardano/mainnet-byron-genesis.json"
"configuration/cardano/mainnet-shelley-genesis.json"
"configuration/cardano/mainnet-alonzo-genesis.json"
];
in
{
# Packages we wish to ignore version bounds of.
# This is similar to jailbreakCabal, however it
# does not require any messing with cabal files.
packages.katip.doExactConfig = true;
# split data output for ekg to reduce closure size
packages.ekg.components.library.enableSeparateDataOutput = true;
# cardano-cli tests depend on cardano-cli and some config files:
packages.cardano-cli.components.tests.cardano-cli-golden.preCheck =
let
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
filteredProjectBase = incl ../. [
"scripts/plutus/scripts/v1/custom-guess-42-datum-42.plutus"
];
in
''
${exportCliPath}
export CARDANO_NODE_SRC=${filteredProjectBase}
'';
packages.cardano-cli.components.tests.cardano-cli-test.preCheck =
let
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
filteredProjectBase = incl ../. mainnetConfigFiles;
in
''
${exportCliPath}
export CARDANO_NODE_SRC=${filteredProjectBase}
'';
packages.cardano-node-chairman.components.tests.chairman-tests.build-tools =
lib.mkForce [
pkgs.lsof
config.hsPkgs.cardano-node.components.exes.cardano-node
config.hsPkgs.cardano-cli.components.exes.cardano-cli
config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman
];
# cardano-node-chairman depends on cardano-node and cardano-cli, and some config files
packages.cardano-node-chairman.preCheck =
let
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
filteredProjectBase = incl ../. [
"configuration/chairman"
"configuration/defaults/byron-mainnet"
"cardano-cli/test/data/golden/alonzo/genesis.alonzo.spec.json"
"scripts/protocol-params.json"
];
in
''
${exportCliPath}
${exportNodePath}
export CARDANO_NODE_CHAIRMAN=${config.hsPkgs.cardano-node-chairman.components.exes.cardano-node-chairman}/bin/cardano-node-chairman${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_NODE_SRC=${filteredProjectBase}
'';
# cardano-testnet depends on cardano-node, cardano-cli, cardano-submit-api and some config files
packages.cardano-testnet.preCheck =
let
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
filteredProjectBase = incl ../. (mainnetConfigFiles ++ [
"configuration/cardano/mainnet-topology.json"
"configuration/defaults/byron-mainnet"
"cardano-cli/test/data/golden/alonzo/genesis.alonzo.spec.json"
"scripts/babbage/alonzo-babbage-test-genesis.json"
]);
in
''
${exportCliPath}
${exportNodePath}
export CARDANO_SUBMIT_API=${config.hsPkgs.cardano-submit-api.components.exes.cardano-submit-api}/bin/cardano-submit-api${pkgs.stdenv.hostPlatform.extensions.executable}
export CARDANO_NODE_SRC=${filteredProjectBase}
'';
})
({ pkgs, ... }: lib.mkIf (!pkgs.stdenv.hostPlatform.isDarwin) {
# Needed for profiled builds to fix an issue loading recursion-schemes part of makeBaseFunctor
# that is missing from the `_p` output. See https://gitlab.haskell.org/ghc/ghc/-/issues/18320
Expand Down Expand Up @@ -206,7 +221,8 @@ let
});
in project.appendOverlays (with haskellLib.projectOverlays; [
projectComponents
(final: prev: let inherit (final.pkgs) lib; in {
(final: prev:
let inherit (final.pkgs) lib gitrev; in {
profiled = final.appendModule {
modules = [{
enableLibraryProfiling = true;
Expand Down
4 changes: 0 additions & 4 deletions nix/update-haskellNix.sh

This file was deleted.

4 changes: 0 additions & 4 deletions nix/update-iohkNix.sh

This file was deleted.

2 changes: 1 addition & 1 deletion nix/workbench/analyse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pkgs.runCommand "workbench-run-analysis-${profileNix.name}"
{ requiredSystemFeatures = [ "benchmark" ];
nativeBuildInputs = with pkgs.haskellPackages; with pkgs;
[ bash coreutils gnused jq moreutils nixWrapped workbench.workbench ];
[ bash coreutils gnused jq moreutils nix workbench.workbench ];
}
''
echo "analysing run: ${run}"
Expand Down
4 changes: 2 additions & 2 deletions nix/workbench/backend/supervisor-run.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in
gnused
jq
moreutils
nixWrapped
nix
pstree
python3Packages.supervisor
workbench.workbench
Expand All @@ -108,7 +108,7 @@ in
--genesis-cache-entry ${genesis}
--batch-name smoke-test
--base-port ${toString basePort}
--node-source ${pkgs.cardanoNodeProject.args.src.origSrc}
--node-source ${pkgs.cardanoNodeProject.args.src}
--node-rev ${cardano-node-rev}
--cache-dir ./cache
)
Expand Down
2 changes: 1 addition & 1 deletion nix/workbench/supervisor-run.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let
gnused
jq
moreutils
nixWrapped
nix
pstree
python3Packages.supervisor
workbench.workbench
Expand Down
7 changes: 5 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let
haskellBuildUtils
pkgs.graphviz
weeder
nixWrapped
nix
pkgconfig
profiteur
profiterole
Expand Down Expand Up @@ -132,7 +132,7 @@ let
packages = _: [];

nativeBuildInputs = with cardanoNodePackages; [
nixWrapped
nix
cardano-cli
bech32
cardano-ping
Expand All @@ -149,6 +149,9 @@ let
pkgs.time
];

# build tools for all hasPkgs not needed (would include duplicates for cardano-cli, cardano-node, etc.)
allToolDeps = false;

shellHook = ''
echo "DevOps Tools" \
| ${figlet}/bin/figlet -f banner -c \
Expand Down