From 5190503cca81203470f5e5e72d622734252ece30 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Mon, 2 Jan 2023 11:18:34 +0100 Subject: [PATCH 01/12] nix: optimize caching by delaying setGitRev other simplification/optimization: - remove generated project-packages-exes.nix (now at eval time) - move rewrite-libs to binary-release.nix: not needed and faster for normal builds - use haskell.nix project overlays to simplify access to components and alternative projects config (profiled, etc.). - filter src to avoid rebuilds for test that depends on $CARDANO_NODE_SRC --- flake.nix | 87 +---- nix/binary-release.nix | 10 +- nix/haskell.nix | 412 +++++++++++++---------- nix/project-packages-exes.nix | 1 - nix/regenerate.sh | 4 - nix/workbench/backend/supervisor-run.nix | 2 +- 6 files changed, 262 insertions(+), 254 deletions(-) delete mode 100644 nix/project-packages-exes.nix diff --git a/flake.nix b/flake.nix index 0c2c969852f..ec879a6c768 100644 --- a/flake.nix +++ b/flake.nix @@ -88,7 +88,6 @@ inherit (utils.lib) eachSystem mkApp flattenTree; inherit (iohkNix.lib) prefixNamesWith; removeRecurse = lib.filterAttrsRecursive (n: _: n != "recurseForDerivations"); - flatten = attrs: lib.foldl' (acc: a: if (lib.isAttrs a) then acc // (removeAttrs a [ "recurseForDerivations" ]) else acc) { } (lib.attrValues attrs); supportedSystems = import ./nix/supported-systems.nix; defaultSystem = head supportedSystems; @@ -123,64 +122,14 @@ self.overlay ]; - projectPackagesExes = import ./nix/project-packages-exes.nix; - - mkPackages = project: + collectExes = project: let inherit (project.pkgs.stdenv) hostPlatform; - inherit (project.pkgs.haskell-nix) haskellLib; - profiledProject = project.appendModule { - modules = [{ - enableLibraryProfiling = true; - packages.cardano-node.components.exes.cardano-node.enableProfiling = true; - packages.tx-generator.components.exes.tx-generator.enableProfiling = true; - packages.locli.components.exes.locli.enableProfiling = true; - }]; - }; - assertedProject = project.appendModule { - modules = [{ - packages = lib.genAttrs [ - "ouroboros-consensus" - "ouroboros-consensus-cardano" - "ouroboros-consensus-cardano-tools" - "ouroboros-consensus-byron" - "ouroboros-consensus-shelley" - "ouroboros-network" - "network-mux" - ] - (name: { flags.asserts = true; }); - }]; - }; - eventloggedProject = project.appendModule - { - modules = [{ - packages = lib.genAttrs [ "cardano-node" ] - (name: { configureFlags = [ "--ghc-option=-eventlog" ]; }); - }]; - }; inherit ((import plutus-apps { inherit (project.pkgs) system; }).plutus-apps.haskell.packages.plutus-example.components.exes) plutus-example; - pinned-workbench = - cardano-node-workbench.workbench.${project.pkgs.system}; - hsPkgsWithPassthru = lib.mapAttrsRecursiveCond (v: !(lib.isDerivation v)) - (path: value: - if (lib.isAttrs value) then - lib.recursiveUpdate value - { - passthru = { - profiled = lib.getAttrFromPath path profiledProject.hsPkgs; - asserted = lib.getAttrFromPath path assertedProject.hsPkgs; - eventlogged = lib.getAttrFromPath path eventloggedProject.hsPkgs; - }; - } else value) - project.hsPkgs; - projectPackages = lib.mapAttrs (n: _: hsPkgsWithPassthru.${n}) projectPackagesExes; - in - { - inherit projectPackages profiledProject assertedProject eventloggedProject; - inherit pinned-workbench; - projectExes = flatten (haskellLib.collectComponents' "exes" projectPackages) // (with hsPkgsWithPassthru; { + + in project.exes // (with project.hsPkgs; { inherit (ouroboros-consensus-byron.components.exes) db-converter; inherit (ouroboros-consensus-cardano.components.exes) db-analyser; inherit (ouroboros-consensus-cardano-tools.components.exes) db-synthesizer; @@ -189,9 +138,8 @@ inherit (network-mux.components.exes) cardano-ping; inherit plutus-example; }); - }; - mkCardanoNodePackages = project: (mkPackages project).projectExes // { + mkCardanoNodePackages = project: (collectExes project) // { inherit (project.pkgs) cardanoLib; }; @@ -208,17 +156,12 @@ project = (import ./nix/haskell.nix { inherit (pkgs) haskell-nix gitrev; - inherit projectPackagesExes; inputMap = { "https://input-output-hk.github.io/cardano-haskell-packages" = CHaP; }; - }).appendModule customConfig.haskellNix // { - profiled = profiledProject; - asserted = assertedProject; - eventlogged = eventloggedProject; - }; + }).appendModule customConfig.haskellNix; - inherit (mkPackages project) projectPackages projectExes profiledProject assertedProject eventloggedProject pinned-workbench; + pinned-workbench = cardano-node-workbench.workbench.${system}; shell = import ./shell.nix { inherit pkgs customConfig cardano-mainnet-mirror; }; devShells = { @@ -234,7 +177,7 @@ inherit pkgs; }; - checks = flattenTree (collectChecks' projectPackages) // + checks = flattenTree project.checks // # Linux only checks: (optionalAttrs hostPlatform.isLinux ( prefixNamesWith "nixosTests/" (mapAttrs (_: v: v.${system} or v) nixosTests) @@ -246,7 +189,7 @@ }; }); - exes = projectExes // { + exes = (collectExes project) // { inherit (pkgs) cabalProjectRegenerate checkCabalProject; "dockerImages/push" = import ./.buildkite/docker-build-push.nix { hostPkgs = import hostNixpkgs { inherit system; }; @@ -260,9 +203,9 @@ ''; } // flattenTree (pkgs.scripts // { # `tests` are the test suites which have been built. - tests = collectComponents' "tests" projectPackages; + inherit (project) tests; # `benchmarks` (only built, not run). - benchmarks = collectComponents' "benchmarks" projectPackages; + inherit (project) benchmarks; }); inherit (pkgs) workbench all-profiles-json supervisord-workbench-nix supervisord-workbench-for-profile; @@ -343,7 +286,7 @@ musl = let muslProject = project.projectCross.musl64; - inherit (mkPackages muslProject) projectPackages projectExes; + projectExes = collectExes muslProject; in projectExes // { cardano-node-linux = import ./nix/binary-release.nix { @@ -357,13 +300,11 @@ windows = let windowsProject = project.projectCross.mingwW64; - inherit (mkPackages windowsProject) projectPackages projectExes; + projectExes = collectExes windowsProject; in projectExes // (removeRecurse { - checks = collectChecks' projectPackages; - tests = collectComponents' "tests" projectPackages; - benchmarks = collectComponents' "benchmarks" projectPackages; + inherit (windowsProject) checks tests benchmarks; cardano-node-win64 = import ./nix/binary-release.nix { inherit pkgs; inherit (exes.cardano-node.identifier) version; @@ -383,7 +324,7 @@ inherit pkgs; inherit (exes.cardano-node.identifier) version; platform = "macos"; - exes = lib.collect lib.isDerivation projectExes; + exes = lib.collect lib.isDerivation (collectExes project); }; shells = removeAttrs devShells [ "profiled" ] // { default = devShell; diff --git a/nix/binary-release.nix b/nix/binary-release.nix index 693e96dee3b..82c0c95dd6a 100644 --- a/nix/binary-release.nix +++ b/nix/binary-release.nix @@ -13,12 +13,12 @@ }: let - lib = pkgs.lib; + inherit (pkgs) lib; name = "cardano-node-${version}-${platform}"; in pkgs.runCommand name { - buildInputs = with pkgs.buildPackages; [ - zip + nativeBuildInputs = with pkgs.pkgsBuildBuild; [ + haskellBuildUtils bintools nix zip ]; } '' mkdir -p $out release @@ -29,6 +29,10 @@ in pkgs.runCommand name { cp -Rv ${../configuration}/* ./configuration/ chmod -R +w . + ${lib.optionalString (platform == "macos") (lib.concatMapStrings (exe: '' + rewrite-libs . ${exe}/bin/* + '') exes)} + ${if (platform == "win64") then "zip -r $out/${name}.zip ." else "tar -czf $out/${name}.tar.gz ." diff --git a/nix/haskell.nix b/nix/haskell.nix index 70f2156ee04..b0958718c27 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix @@ -4,193 +4,261 @@ { haskell-nix , # Version info (git revision) gitrev -, # Pre-computed package list (generated by nix/regenerate.sh) to avoid double evaluation: - projectPackagesExes , inputMap }: let inherit (haskell-nix) haskellLib; - projectPackageNames = builtins.attrNames projectPackagesExes; - # This creates the Haskell package set. # https://input-output-hk.github.io/haskell.nix/user-guide/projects/ + project = haskell-nix.cabalProject' ({ pkgs + , lib + , config + , 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; + compiler-nix-name = "ghc8107"; + cabalProjectLocal = '' + allow-newer: terminfo:base + '' + lib.optionalString pkgs.stdenv.hostPlatform.isWindows '' + -- When cross compiling we don't have a `ghc` package + package plutus-tx-plugin + flags: +use-ghc-stub + ''; + shell = { + name = "cabal-dev-shell"; -in -haskell-nix.cabalProject' ({ pkgs - , lib - , config - , buildProject - , ... - }: { - inherit inputMap; - name = "cardano-node"; - src = haskellLib.cleanSourceWith { - src = ../.; - name = "cardano-node-src"; - filter = name: type: (lib.cleanSourceFilter name type) - && (haskell-nix.haskellSourceFilter name type) - # removes socket files - && lib.elem type [ "regular" "directory" "symlink" ]; - }; - compiler-nix-name = "ghc8107"; - cabalProjectLocal = '' - allow-newer: terminfo:base - '' + lib.optionalString pkgs.stdenv.hostPlatform.isWindows '' - -- When cross compiling we don't have a `ghc` package - package plutus-tx-plugin - flags: +use-ghc-stub - ''; - shell = { - name = "cabal-dev-shell"; - - # These programs will be available inside the nix-shell. - nativeBuildInputs = with pkgs.buildPackages.buildPackages; [ - nix-prefetch-git - pkg-config - hlint - ghcid - haskell-language-server - cabal - ]; + # These programs will be available inside the nix-shell. + nativeBuildInputs = with pkgs.pkgsBuildBuild; [ + nix-prefetch-git + pkg-config + hlint + ghcid + haskell-language-server + cabal + ]; - withHoogle = true; - }; - modules = - let - inherit (config) src; - # setGitRev is a postInstall script to stamp executables with - # version info. It uses the "gitrev" argument, if set. Otherwise, - # the revision is sourced from the local git work tree. - setGitRev = ''${pkgs.buildPackages.haskellBuildUtils}/bin/set-git-rev "${gitrev}" $out/bin/*''; - in - [ - ({ pkgs, ... }: { - packages.tx-generator.package.buildable = with pkgs.stdenv.hostPlatform; isUnix && !isMusl; - packages.cardano-tracer.package.buildable = with pkgs.stdenv.hostPlatform; isUnix && !isMusl; - packages.cardano-node-chairman.components.tests.chairman-tests.buildable = lib.mkForce pkgs.stdenv.hostPlatform.isUnix; - packages.plutus-tx-plugin.components.library.platforms = with lib.platforms; [ linux darwin ]; - }) - ({ pkgs, ... }: { - # Needed for the CLI tests. - # Coreutils because we need 'paste'. - packages.cardano-cli.components.tests.cardano-cli-test.build-tools = - lib.mkForce (with pkgs.buildPackages; [ jq coreutils shellcheck ]); - packages.cardano-cli.components.tests.cardano-cli-golden.build-tools = - lib.mkForce (with pkgs.buildPackages; [ jq coreutils shellcheck ]); - packages.cardano-testnet.components.tests.cardano-testnet-tests.build-tools = - lib.mkForce (with pkgs.buildPackages; [ jq coreutils shellcheck lsof ]); - }) - ({ pkgs, ... }: { - # Use the VRF fork of libsodium - packages.cardano-crypto-praos.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf ] ]; - packages.cardano-crypto-class.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ]; - }) - ({ pkgs, options, ... }: { - # make sure that libsodium DLLs are available for windows binaries, - # stamp executables with the git revision, add shell completion, strip/rewrite: - packages = lib.mapAttrs - (name: exes: { - components.exes = lib.genAttrs exes (exe: { - postInstall = '' - ${setGitRev} - ${lib.optionalString (pkgs.stdenv.hostPlatform.isMusl) '' - ${pkgs.buildPackages.binutils-unwrapped}/bin/*strip $out/bin/* - ''} - ${lib.optionalString (pkgs.stdenv.hostPlatform.isDarwin) '' - export PATH=$PATH:${lib.makeBinPath [ pkgs.haskellBuildUtils pkgs.buildPackages.binutils pkgs.buildPackages.nix ]} - ${pkgs.haskellBuildUtils}/bin/rewrite-libs $out/bin $out/bin/* - ''} - ${lib.optionalString (!pkgs.stdenv.hostPlatform.isWindows + withHoogle = true; + }; + modules = + let + inherit (config) src; + # deduce package names and exes from the cabal project to avoid hard-coding them: + projectPackagesExes = + let + project = haskell-nix.cabalProject' (builtins.removeAttrs config ["modules"]); + packages = haskellLib.selectProjectPackages project.hsPkgs; + in + lib.genAttrs + (lib.attrNames packages) + (name: lib.attrNames packages.${name}.components.exes); + projectPackageNames = builtins.attrNames projectPackagesExes; + in + [ + ({ pkgs, ... }: { + packages.tx-generator.package.buildable = with pkgs.stdenv.hostPlatform; isUnix && !isMusl; + packages.cardano-tracer.package.buildable = with pkgs.stdenv.hostPlatform; isUnix && !isMusl; + packages.cardano-node-chairman.components.tests.chairman-tests.buildable = lib.mkForce pkgs.stdenv.hostPlatform.isUnix; + packages.plutus-tx-plugin.components.library.platforms = with lib.platforms; [ linux darwin ]; + }) + ({ pkgs, ... }: { + # Needed for the CLI tests. + # Coreutils because we need 'paste'. + packages.cardano-cli.components.tests.cardano-cli-test.build-tools = + lib.mkForce (with pkgs.buildPackages; [ jq coreutils shellcheck ]); + packages.cardano-cli.components.tests.cardano-cli-golden.build-tools = + lib.mkForce (with pkgs.buildPackages; [ jq coreutils shellcheck ]); + packages.cardano-testnet.components.tests.cardano-testnet-tests.build-tools = + lib.mkForce (with pkgs.buildPackages; [ jq coreutils shellcheck lsof ]); + }) + ({ pkgs, ... }: { + # Use the VRF fork of libsodium + packages.cardano-crypto-praos.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf ] ]; + packages.cardano-crypto-class.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ]; + }) + ({ pkgs, options, ... }: { + # add shell completion: + packages = lib.mapAttrs + (name: exes: { + components.exes = lib.genAttrs exes (exe: { + postInstall = lib.optionalString (!pkgs.stdenv.hostPlatform.isWindows && lib.elem exe ["cardano-node" "cardano-cli" "cardano-topology" "locli"]) '' BASH_COMPLETIONS=$out/share/bash-completion/completions ZSH_COMPLETIONS=$out/share/zsh/site-functions mkdir -p $BASH_COMPLETIONS $ZSH_COMPLETIONS $out/bin/${exe} --bash-completion-script ${exe} > $BASH_COMPLETIONS/${exe} $out/bin/${exe} --zsh-completion-script ${exe} > $ZSH_COMPLETIONS/_${exe} - ''} - ''; - }); - }) - 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 - 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 - 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 - 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, ... }: 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 - # This work around currently breaks regular builds on macOS with: - # : error: ghc: ghc-iserv terminated (-11) - packages.plutus-core.components.library.ghcOptions = [ "-fexternal-interpreter" ]; - }) - { - packages = lib.genAttrs projectPackageNames - (name: { configureFlags = [ "--ghc-option=-Werror" ]; }); - } - ({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isLinux { - # systemd can't be statically linked - packages.cardano-git-rev.flags.systemd = !pkgs.stdenv.hostPlatform.isMusl; - packages.cardano-node.flags.systemd = !pkgs.stdenv.hostPlatform.isMusl; - packages.cardano-tracer.flags.systemd = !pkgs.stdenv.hostPlatform.isMusl; - }) - # Musl libc fully static build - ({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isMusl ( - let - # Module options which adds GHC flags and libraries for a fully static build - fullyStaticOptions = { - enableShared = false; - enableStatic = true; - }; - in + ''; + }); + }) + 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 + 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 + 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 + 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, ... }: 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 + # This work around currently breaks regular builds on macOS with: + # : error: ghc: ghc-iserv terminated (-11) + packages.plutus-core.components.library.ghcOptions = [ "-fexternal-interpreter" ]; + }) { - packages = lib.genAttrs projectPackageNames (name: fullyStaticOptions); - # Haddock not working and not needed for cross builds - doHaddock = false; + packages = lib.genAttrs projectPackageNames + (name: { configureFlags = [ "--ghc-option=-Werror" ]; }); } - )) - ({ pkgs, ... }: lib.mkIf (pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform) { - # Remove hsc2hs build-tool dependencies (suitable version will be available as part of the ghc derivation) - packages.Win32.components.library.build-tools = lib.mkForce [ ]; - packages.terminal-size.components.library.build-tools = lib.mkForce [ ]; - packages.network.components.library.build-tools = lib.mkForce [ ]; - }) - # TODO add flags to packages (like cs-ledger) so we can turn off tests that will - # not build for windows on a per package bases (rather than using --disable-tests). - # configureArgs = lib.optionalString stdenv.hostPlatform.isWindows "--disable-tests"; - ]; -}) + ({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isLinux { + # systemd can't be statically linked + packages.cardano-git-rev.flags.systemd = !pkgs.stdenv.hostPlatform.isMusl; + packages.cardano-node.flags.systemd = !pkgs.stdenv.hostPlatform.isMusl; + packages.cardano-tracer.flags.systemd = !pkgs.stdenv.hostPlatform.isMusl; + }) + # Musl libc fully static build + ({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isMusl ( + let + # Module options which adds GHC flags and libraries for a fully static build + fullyStaticOptions = { + enableShared = false; + enableStatic = true; + }; + in + { + packages = lib.genAttrs projectPackageNames (name: fullyStaticOptions); + # Haddock not working and not needed for cross builds + doHaddock = false; + } + )) + ({ pkgs, ... }: lib.mkIf (pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform) { + # Remove hsc2hs build-tool dependencies (suitable version will be available as part of the ghc derivation) + packages.Win32.components.library.build-tools = lib.mkForce [ ]; + packages.terminal-size.components.library.build-tools = lib.mkForce [ ]; + packages.network.components.library.build-tools = lib.mkForce [ ]; + }) + # TODO add flags to packages (like cs-ledger) so we can turn off tests that will + # not build for windows on a per package bases (rather than using --disable-tests). + # configureArgs = lib.optionalString stdenv.hostPlatform.isWindows "--disable-tests"; + ]; + }); +in project.appendOverlays (with haskellLib.projectOverlays; [ + projectComponents + (final: prev: let inherit (final.pkgs) lib; in { + profiled = final.appendModule { + modules = [{ + enableLibraryProfiling = true; + packages.cardano-node.components.exes.cardano-node.enableProfiling = true; + packages.tx-generator.components.exes.tx-generator.enableProfiling = true; + packages.locli.components.exes.locli.enableProfiling = true; + }]; + }; + asserted = final.appendModule { + modules = [{ + packages = lib.genAttrs [ + "ouroboros-consensus" + "ouroboros-consensus-cardano" + "ouroboros-consensus-cardano-tools" + "ouroboros-consensus-byron" + "ouroboros-consensus-shelley" + "ouroboros-network" + "network-mux" + ] + (name: { flags.asserts = true; }); + }]; + }; + eventlogged = final.appendModule + { + modules = [{ + packages = final.pkgs.lib.genAttrs [ "cardano-node" ] + (name: { configureFlags = [ "--ghc-option=-eventlog" ]; }); + }]; + }; + # add passthru and gitrev to hsPkgs: + hsPkgs = lib.mapAttrsRecursiveCond (v: !(lib.isDerivation v)) + (path: value: + if (lib.isAttrs value) then + lib.recursiveUpdate + (if lib.elemAt path 2 == "exes" && lib.elem (lib.elemAt path 3) [ "cardano-node" "cardano-cli" ] then + # Stamp executables with version info. + # Done outside the haskell.nix derivation to avoid compilation and tests depending on rev. + final.pkgs.buildPackages.runCommand value.name + { + inherit (value) exeName exePath meta passthru; + } '' + mkdir -p $out + cp --no-preserve=timestamps --recursive ${value}/* $out/ + chmod -R +w $out/bin + ${final.pkgs.pkgsBuildBuild.haskellBuildUtils}/bin/set-git-rev "${gitrev}" $out/bin/* + '' + else value) + { + # Also add convenient passthru to some alternative compilation configurations: + passthru = { + profiled = lib.getAttrFromPath path final.profiled.hsPkgs; + asserted = lib.getAttrFromPath path final.asserted.hsPkgs; + eventlogged = lib.getAttrFromPath path final.eventlogged.hsPkgs; + }; + } else value) + prev.hsPkgs; + }) +]) diff --git a/nix/project-packages-exes.nix b/nix/project-packages-exes.nix deleted file mode 100644 index 595c8dcd8d0..00000000000 --- a/nix/project-packages-exes.nix +++ /dev/null @@ -1 +0,0 @@ -{ cardano-api = [ ]; cardano-cli = [ "cardano-cli" ]; cardano-client-demo = [ "chain-sync-client-with-ledger-state" "ledger-state" "scan-blocks" "scan-blocks-pipelined" "stake-credential-history" ]; cardano-git-rev = [ ]; cardano-node = [ "cardano-node" ]; cardano-node-capi = [ ]; cardano-node-chairman = [ "cardano-node-chairman" ]; cardano-submit-api = [ "cardano-submit-api" ]; cardano-testnet = [ "cardano-testnet" ]; cardano-topology = [ "cardano-topology" ]; cardano-tracer = [ "cardano-tracer" "demo-acceptor" "demo-forwarder" ]; locli = [ "locli" ]; trace-dispatcher = [ "trace-dispatcher-examples" ]; trace-forward = [ ]; trace-resources = [ ]; tx-generator = [ "tx-generator" ]; } diff --git a/nix/regenerate.sh b/nix/regenerate.sh index 27c19b50bd4..f8d78cc02c7 100755 --- a/nix/regenerate.sh +++ b/nix/regenerate.sh @@ -3,7 +3,3 @@ set -euo pipefail cd $(git rev-parse --show-toplevel) nix run .#cabalProjectRegenerate - -# Regenerate the list of the project packages: -nix eval .#pkgs.genProjectPackages > nix/project-packages-exes.nix.new -mv nix/project-packages-exes.nix.new nix/project-packages-exes.nix diff --git a/nix/workbench/backend/supervisor-run.nix b/nix/workbench/backend/supervisor-run.nix index f1b4f890e2f..422d490d5bc 100644 --- a/nix/workbench/backend/supervisor-run.nix +++ b/nix/workbench/backend/supervisor-run.nix @@ -108,7 +108,7 @@ in --genesis-cache-entry ${genesis} --batch-name smoke-test --base-port ${toString basePort} - --node-source ${cardanoNodePackages.cardano-node.src.origSrc} + --node-source ${pkgs.cardanoNodeProject.args.src.origSrc} --node-rev ${cardano-node-rev} --cache-dir ./cache ) From 84969daadcddb343e1fedbfaca6fc74013a996ca Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Wed, 4 Jan 2023 15:55:09 +0100 Subject: [PATCH 02/12] bump iohkNix to include libsodium fix for mingwW64 --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 2445fe8e779..07224e6f1cd 100644 --- a/flake.lock +++ b/flake.lock @@ -4555,11 +4555,11 @@ ] }, "locked": { - "lastModified": 1667394105, - "narHash": "sha256-YhS7zGd6jK/QM/+wWyj0zUBZmE3HOXAL/kpJptGYIWg=", + "lastModified": 1672846257, + "narHash": "sha256-khuzjVfyNCVcsV5cHRyyb2OgWLbYLKSJlrVDNmc2Tv4=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "7fc7625a9ab2ba137bc70ddbc89a13d3fdb78c8b", + "rev": "ca3d466ed36011bcc14290c6d36c503eb03eb71b", "type": "github" }, "original": { From 1354c69a3adb9d874d7c8ef8f19f14da135ce77b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Fri, 6 Jan 2023 15:11:37 +0100 Subject: [PATCH 03/12] fix required jobs, rename systemHydraJobs to ciJobs. --- flake.nix | 231 ++++++++++++++++++++++++------------------------------ 1 file changed, 104 insertions(+), 127 deletions(-) diff --git a/flake.nix b/flake.nix index ec879a6c768..1055579c93d 100644 --- a/flake.nix +++ b/flake.nix @@ -220,9 +220,6 @@ // optionalAttrs (system == "x86_64-linux") rec { "dockerImage/node" = pkgs.dockerImage; "dockerImage/submit-api" = pkgs.submitApiDockerImage; - ## TODO: drop external membench, once we bump 'node-snapshot' - # snapshot = membench.outputs.packages.x86_64-linux.snapshot; - # membenches = pkgs.membench-node-this-5.batch-report; # workbench-smoke-test = # (pkgs.supervisord-workbench-for-profile # { @@ -246,80 +243,58 @@ apps = lib.mapAttrs (n: p: { type = "app"; program = p.exePath or (if (p.executable or false) then "${p}" else "${p}/bin/${p.name or n}"); }) exes; - in - { - - inherit environments packages checks apps project; - - legacyPackages = pkgs; - - # Built by `nix build .` - defaultPackage = packages.cardano-node; - - # Run by `nix run .` - defaultApp = apps.cardano-node; - - # This is used by `nix develop .` to open a devShell - inherit devShell devShells; - - # The parametrisable workbench. - inherit workbench; - - systemHydraJobs = optionalAttrs (system == "x86_64-linux") - { - linux = { - native = packages // { - shells = devShells // { - default = devShell; - }; - internal = { - roots.project = project.roots; - plan-nix.project = project.plan-nix; - }; - profiled = lib.genAttrs [ "cardano-node" "tx-generator" "locli" ] (n: - packages.${n}.passthru.profiled - ); - asserted = lib.genAttrs [ "cardano-node" ] (n: - packages.${n}.passthru.asserted - ); + ciJobs = let ciJobs = { + cardano-deployment = pkgs.cardanoLib.mkConfigHtml { inherit (pkgs.cardanoLib.environments) mainnet testnet; }; + } // optionalAttrs (system == "x86_64-linux") { + native = packages // { + shells = devShells // { + default = devShell; + }; + internal = { + roots.project = project.roots; + plan-nix.project = project.plan-nix; + }; + profiled = lib.genAttrs [ "cardano-node" "tx-generator" "locli" ] (n: + packages.${n}.passthru.profiled + ); + asserted = lib.genAttrs [ "cardano-node" ] (n: + packages.${n}.passthru.asserted + ); + }; + musl = + let + muslProject = project.projectCross.musl64; + projectExes = collectExes muslProject; + in + projectExes // { + cardano-node-linux = import ./nix/binary-release.nix { + inherit pkgs; + inherit (exes.cardano-node.identifier) version; + platform = "linux"; + exes = lib.collect lib.isDerivation projectExes; }; - musl = - let - muslProject = project.projectCross.musl64; - projectExes = collectExes muslProject; - in - projectExes // { - cardano-node-linux = import ./nix/binary-release.nix { - inherit pkgs; - inherit (exes.cardano-node.identifier) version; - platform = "linux"; - exes = lib.collect lib.isDerivation projectExes; - }; - internal.roots.project = muslProject.roots; - }; - windows = - let - windowsProject = project.projectCross.mingwW64; - projectExes = collectExes windowsProject; - in - projectExes - // (removeRecurse { - inherit (windowsProject) checks tests benchmarks; - cardano-node-win64 = import ./nix/binary-release.nix { - inherit pkgs; - inherit (exes.cardano-node.identifier) version; - platform = "win64"; - exes = lib.collect lib.isDerivation projectExes; - }; - internal.roots.project = windowsProject.roots; - }); + internal.roots.project = muslProject.roots; }; - } // optionalAttrs (system == "x86_64-darwin") { - macos = lib.filterAttrs - (n: _: - # only build docker images once on linux: - !(lib.hasPrefix "dockerImage" n)) - packages // { + windows = + let + windowsProject = project.projectCross.mingwW64; + projectExes = collectExes windowsProject; + in + projectExes + // (removeRecurse { + inherit (windowsProject) checks tests benchmarks; + cardano-node-win64 = import ./nix/binary-release.nix { + inherit pkgs; + inherit (exes.cardano-node.identifier) version; + platform = "win64"; + exes = lib.collect lib.isDerivation projectExes; + }; + internal.roots.project = windowsProject.roots; + }); + } // optionalAttrs (system == "x86_64-darwin") { + native = lib.filterAttrs (n: _: + # only build docker images once on linux: + !(lib.hasPrefix "dockerImage" n)) packages // { cardano-node-macos = import ./nix/binary-release.nix { inherit pkgs; inherit (exes.cardano-node.identifier) version; @@ -335,65 +310,67 @@ }; }; }; - } - ); + defaultNonRequiredPaths = [ "windows.checks.cardano-tracer.cardano-tracer-test" ] ++ + lib.optionals (system == "x86_64-darwin") [ + #FIXME: ExceptionInLinkedThread (ThreadId 253) pokeSockAddr: path is too long + "native.checks/cardano-testnet/cardano-testnet-tests" + ]; + in pkgs.callPackages iohkNix.utils.ciJobsAggregates { + inherit ciJobs; + nonRequiredPaths = map lib.hasPrefix defaultNonRequiredPaths; + } // { + pr = pkgs.callPackages iohkNix.utils.ciJobsAggregates { + inherit ciJobs; + nonRequiredPaths = map lib.hasPrefix (defaultNonRequiredPaths ++ [ + "native.membenches" + ]); + }; + } // ciJobs; - makeRequired = isPr: jobs: extra: - let - nonRequiredPaths = map lib.hasPrefix ([ "macos." ] ++ lib.optional isPr "linux.native.membenches"); - in with self.legacyPackages.${defaultSystem}; - releaseTools.aggregate { - name = "github-required"; - meta.description = "All jobs required to pass CI"; - constituents = lib.collect lib.isDerivation - (lib.mapAttrsRecursiveCond (v: !(lib.isDerivation v)) - (path: value: - let stringPath = lib.concatStringsSep "." path; in if lib.isAttrs value && (lib.any (p: p stringPath) nonRequiredPaths) then { } else value) - jobs) ++ extra; - }; + in + { - makeOsRequired = isPr: jobs: { - linux = jobs.linux // { - required = makeRequired isPr jobs.linux []; - }; - macos = jobs.macos // { - required = makeRequired isPr jobs.macos []; - }; - }; + inherit environments packages checks apps project ciJobs; - hydraJobs = - let - jobs = lib.foldl' lib.mergeAttrs { } (lib.attrValues flake.systemHydraJobs); - in - jobs // (with self.legacyPackages.${defaultSystem}; rec { - cardano-deployment = cardanoLib.mkConfigHtml { inherit (cardanoLib.environments) mainnet testnet; }; - build-version = writeText "version.json" (builtins.toJSON { - inherit (self) lastModified lastModifiedDate narHash outPath shortRev rev; - }); - required = makeRequired false jobs [ cardano-deployment build-version ]; - }) // makeOsRequired false jobs; + legacyPackages = pkgs // { + # allows access to hydraJobs with specifying : + hydraJobs = ciJobs; + }; - hydraJobsPr = - let - nonPrJobs = map lib.hasPrefix [ - "linux.native.membenches" - "linux.native.workbench-ci-analysis" - "linux.native.workbench-ci-test" - ]; - - jobs = lib.mapAttrsRecursiveCond (v: !(lib.isDerivation v)) - (path: value: - let stringPath = lib.concatStringsSep "." path; in if lib.isAttrs value && (lib.any (p: p stringPath) nonPrJobs) then { } else value) - hydraJobs; - in - jobs // { - required = makeRequired true jobs [ hydraJobs.cardano-deployment hydraJobs.build-version ]; - } // makeOsRequired true jobs; - in - builtins.removeAttrs flake [ "systemHydraJobs" ] // { + # Built by `nix build .` + defaultPackage = packages.cardano-node; + + # Run by `nix run .` + defaultApp = apps.cardano-node; + + # This is used by `nix develop .` to open a devShell + inherit devShell devShells; + + # The parametrisable workbench. + inherit workbench; + + } + ); + + hydraJobs = flake.ciJobs // { + # TODO: remove nex 3 lines once tullia config reference architecture directly: + inherit (flake.ciJobs.${defaultSystem}) cardano-deployment; + linux.required = flake.ciJobs.x86_64-linux.required or {}; + macos.required = flake.ciJobs.x86_64-darwin.required or {}; + }; + # TODO: also hydraJobsPr remove once tullia config reference hydraJobs..pr: + hydraJobsPr = { + inherit (flake.ciJobs.${defaultSystem}) cardano-deployment; + linux.required = flake.ciJobs.x86_64-linux.pr.required or {}; + macos.required = flake.ciJobs.x86_64-darwin.pr.required or {}; + }; + in removeAttrs flake ["ciJobs"] // { inherit hydraJobs hydraJobsPr; + # allows precise paths (avoid fallbacks) with nix build/eval: + outputs = self; + overlay = final: prev: { cardanoNodeProject = flake.project.${final.system}; cardanoNodePackages = mkCardanoNodePackages final.cardanoNodeProject; From fb2bd2edcd9ee925a5eb58c1c45e5508029f5d96 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Wed, 11 Jan 2023 10:30:47 +0100 Subject: [PATCH 04/12] switch bors to use ci/required --- bors.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bors.toml b/bors.toml index 4520331d68d..0d58d9d1e3a 100644 --- a/bors.toml +++ b/bors.toml @@ -1,5 +1,5 @@ status = [ - "ci/push", + "ci/push/required", ] timeout_sec = 7200 required_approvals = 1 From e6f8db893c30cee2602e41523ea838671165f437 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Wed, 11 Jan 2023 11:04:59 +0100 Subject: [PATCH 05/12] haskell.nix: add some TODO regarding unwanted dependencies on `src`. also for profiled project, activate profiling for all exes to avoid surprises --- nix/haskell.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nix/haskell.nix b/nix/haskell.nix index b0958718c27..faaaf47274c 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix @@ -130,6 +130,7 @@ let # 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} @@ -142,6 +143,7 @@ let 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} @@ -149,6 +151,7 @@ let 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} @@ -207,9 +210,7 @@ in project.appendOverlays (with haskellLib.projectOverlays; [ profiled = final.appendModule { modules = [{ enableLibraryProfiling = true; - packages.cardano-node.components.exes.cardano-node.enableProfiling = true; - packages.tx-generator.components.exes.tx-generator.enableProfiling = true; - packages.locli.components.exes.locli.enableProfiling = true; + enableProfiling = true; }]; }; asserted = final.appendModule { From 52567bbce924d6f8432392d33a8870bdb38b9e46 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Thu, 10 Nov 2022 16:02:33 +0100 Subject: [PATCH 06/12] Update plutus-apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix issue when entering `nix develop .#devops`: ``` error: the path '~/.gitconfig' can not be resolved in pure mode … while evaluating the attribute 'gitignoreFilter' ``` --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 07224e6f1cd..ad0c7c6730c 100644 --- a/flake.lock +++ b/flake.lock @@ -7681,11 +7681,11 @@ "plutus-apps_4": { "flake": false, "locked": { - "lastModified": 1647347289, - "narHash": "sha256-dxKZ1Zvflyt6igYm39POV6X/0giKbfb4U7D1TvevQls=", + "lastModified": 1668055541, + "narHash": "sha256-c0XuranD91kZ7uR0gemZQOFDNRv3pFXunJC4j064mtc=", "owner": "input-output-hk", "repo": "plutus-apps", - "rev": "2a40552f4654d695f21783c86e8ae59243ce9dfa", + "rev": "1651d36a0f6458e7d2326d57dbc1baa00034d70d", "type": "github" }, "original": { From 45630333d305dba1aa81e3573beec49c2a1d6fb5 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Wed, 18 Jan 2023 11:33:48 +0100 Subject: [PATCH 07/12] node nixos service: fix path of profiled, eventlogged and asserted binaries --- nix/nixos/cardano-node-service.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/nixos/cardano-node-service.nix b/nix/nixos/cardano-node-service.nix index 96f17d3cb12..69e981d6f67 100644 --- a/nix/nixos/cardano-node-service.nix +++ b/nix/nixos/cardano-node-service.nix @@ -191,9 +191,9 @@ in { package = mkOption { type = types.package; default = if (cfg.profiling != "none") - then cfg.cardanoNodePackages.cardano-node.profiled - else if cfg.eventlog then cfg.cardanoNodePackages.cardano-node.eventlogged - else if cfg.asserts then cfg.cardanoNodePackages.cardano-node.asserted + then cfg.cardanoNodePackages.cardano-node.passthru.profiled + else if cfg.eventlog then cfg.cardanoNodePackages.cardano-node.passthru.eventlogged + else if cfg.asserts then cfg.cardanoNodePackages.cardano-node.passthru.asserted else cfg.cardanoNodePackages.cardano-node; defaultText = "cardano-node"; description = '' From 94fbab4fb86bab65a08bad70ac9d9d72b39e35b5 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Wed, 18 Jan 2023 11:40:14 +0100 Subject: [PATCH 08/12] fix index-state and version of tools to avoid rebuilds and compile errors --- nix/pkgs.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nix/pkgs.nix b/nix/pkgs.nix index d8fb33173f6..0a5eb75b507 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -9,29 +9,26 @@ final: prev: with final; { cardanoNodeProject.hsPkgs)) (name: lib.attrNames cardanoNodeProject.pkg-set.options.packages.value.${name}.components.exes); - cabal = haskell-nix.tool compiler-nix-name "cabal" { - version = "latest"; - inherit (cardanoNodeProject) index-state; - }; + cabal = haskell-nix.cabal-install.${compiler-nix-name}; hlint = haskell-nix.tool compiler-nix-name "hlint" { version = "3.2.7"; - inherit (cardanoNodeProject) index-state; + index-state = "2022-09-27T00:00:00Z"; }; ghcid = haskell-nix.tool compiler-nix-name "ghcid" { version = "0.8.7"; - inherit (cardanoNodeProject) index-state; + index-state = "2022-09-27T00:00:00Z"; }; haskell-language-server = haskell-nix.tool compiler-nix-name "haskell-language-server" { - version = "latest"; - inherit (cardanoNodeProject) index-state; + version = "1.8.0.0"; + index-state = "2022-09-27T00:00:00Z"; }; haskellBuildUtils = prev.haskellBuildUtils.override { inherit compiler-nix-name; - inherit (cardanoNodeProject) index-state; + index-state = "2022-09-27T00:00:00Z"; }; cardanolib-py = callPackage ./cardanolib-py { }; From 541b50255c7399855050f4c153526880b4dedca3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Mon, 16 Jan 2023 15:33:42 +0100 Subject: [PATCH 09/12] flake: move devShell to devShells.default --- flake.nix | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 1055579c93d..f757b1f1a61 100644 --- a/flake.nix +++ b/flake.nix @@ -166,12 +166,11 @@ shell = import ./shell.nix { inherit pkgs customConfig cardano-mainnet-mirror; }; devShells = { inherit (shell) devops; + default = shell.dev; cluster = shell; profiled = project.profiled.shell; }; - devShell = shell.dev; - # NixOS tests run a node and submit-api and validate it listens nixosTests = import ./nix/nixos/tests { inherit pkgs; @@ -247,9 +246,7 @@ cardano-deployment = pkgs.cardanoLib.mkConfigHtml { inherit (pkgs.cardanoLib.environments) mainnet testnet; }; } // optionalAttrs (system == "x86_64-linux") { native = packages // { - shells = devShells // { - default = devShell; - }; + shells = devShells; internal = { roots.project = project.roots; plan-nix.project = project.plan-nix; @@ -301,9 +298,7 @@ platform = "macos"; exes = lib.collect lib.isDerivation (collectExes project); }; - shells = removeAttrs devShells [ "profiled" ] // { - default = devShell; - }; + shells = removeAttrs devShells [ "profiled" ]; internal = { roots.project = project.roots; plan-nix.project = project.plan-nix; @@ -344,7 +339,7 @@ defaultApp = apps.cardano-node; # This is used by `nix develop .` to open a devShell - inherit devShell devShells; + inherit devShells; # The parametrisable workbench. inherit workbench; From 3c14f222db41c19897ee60f94990d3ea75144525 Mon Sep 17 00:00:00 2001 From: John Ky Date: Thu, 5 Jan 2023 08:54:45 +1100 Subject: [PATCH 10/12] Specify Github token in install-nix-action configuration --- .github/workflows/check-mainnet-config.yml | 2 ++ .github/workflows/check-nix-config.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/check-mainnet-config.yml b/.github/workflows/check-mainnet-config.yml index e486e43e100..ddd1b7be938 100644 --- a/.github/workflows/check-mainnet-config.yml +++ b/.github/workflows/check-mainnet-config.yml @@ -16,7 +16,9 @@ jobs: - name: Install Nix uses: cachix/install-nix-action@v16 with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} experimental-features = nix-command flakes allow-import-from-derivation = true substituters = https://cache.nixos.org https://hydra.iohk.io diff --git a/.github/workflows/check-nix-config.yml b/.github/workflows/check-nix-config.yml index b1c056c5512..8b818acea20 100644 --- a/.github/workflows/check-nix-config.yml +++ b/.github/workflows/check-nix-config.yml @@ -16,6 +16,7 @@ jobs: - name: Install Nix uses: cachix/install-nix-action@v16 with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} extra_nix_config: | experimental-features = nix-command flakes allow-import-from-derivation = true From d992b7261e8f4ea3a5324050d04f6f5526d6dae2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Tue, 24 Jan 2023 10:06:24 +0100 Subject: [PATCH 11/12] bump cachix/install-nix-action to v18. fix channel to nixos-22.11. fix cache. --- .github/workflows/check-mainnet-config.yml | 7 +++++-- .github/workflows/check-nix-config.yml | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-mainnet-config.yml b/.github/workflows/check-mainnet-config.yml index ddd1b7be938..ff1898a4475 100644 --- a/.github/workflows/check-mainnet-config.yml +++ b/.github/workflows/check-mainnet-config.yml @@ -14,15 +14,18 @@ jobs: steps: - name: Install Nix - uses: cachix/install-nix-action@v16 + uses: cachix/install-nix-action@v18 with: + # Use last stable nixos channel and the same nix as in channel: + install_url: https://releases.nixos.org/nix/nix-2.11.1/install + nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} experimental-features = nix-command flakes allow-import-from-derivation = true substituters = https://cache.nixos.org https://hydra.iohk.io - trusted-public-keys = iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= - uses: actions/checkout@v2 diff --git a/.github/workflows/check-nix-config.yml b/.github/workflows/check-nix-config.yml index 8b818acea20..a3a6d5a8536 100644 --- a/.github/workflows/check-nix-config.yml +++ b/.github/workflows/check-nix-config.yml @@ -14,14 +14,18 @@ jobs: steps: - name: Install Nix - uses: cachix/install-nix-action@v16 + uses: cachix/install-nix-action@v18 with: + # Use last stable nixos channel and the same nix as in channel: + install_url: https://releases.nixos.org/nix/nix-2.11.1/install + nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} experimental-features = nix-command flakes allow-import-from-derivation = true - substituters = https://cache.nixos.org https://hydra.iohk.io - trusted-public-keys = iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://cache.nixos.org https://cache.iog.io + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= - uses: actions/checkout@v2 From 7d64f79fec0c2a857c3526525809f78fcafe416b Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 18 Jan 2023 11:15:54 +0100 Subject: [PATCH 12/12] Use hedgehog-extras-0.2.0.0 This works for both `nix` and `cabal`. --- cabal.project | 1 + cardano-testnet/test/Spec/Cli/Babbage/LeadershipSchedule.hs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index f2ffd717ded..dc900b0361a 100644 --- a/cabal.project +++ b/cabal.project @@ -77,6 +77,7 @@ test-show-details: direct constraints: hedgehog >= 1.0 + , hedgehog-extras == 0.2.0.0 , bimap >= 0.4.0 , libsystemd-journal >= 1.4.4 , systemd >= 2.3.0 diff --git a/cardano-testnet/test/Spec/Cli/Babbage/LeadershipSchedule.hs b/cardano-testnet/test/Spec/Cli/Babbage/LeadershipSchedule.hs index 7ff2dcdf8d8..2efe4e4d6bb 100644 --- a/cardano-testnet/test/Spec/Cli/Babbage/LeadershipSchedule.hs +++ b/cardano-testnet/test/Spec/Cli/Babbage/LeadershipSchedule.hs @@ -116,7 +116,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" leadershipScheduleDeadline <- H.noteShowM $ DTC.addUTCTime 180 <$> H.noteShowIO DTC.getCurrentTime - H.byDeadlineM 5 leadershipScheduleDeadline "leadershipSchedule:current:error" $ do + H.byDeadlineM 5 leadershipScheduleDeadline $ do void $ H.execCli' execConfig [ "query", "leadership-schedule" , "--testnet-magic", show @Int testnetMagic @@ -157,7 +157,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" leadershipScheduleDeadline <- H.noteShowM $ DTC.addUTCTime 180 <$> H.noteShowIO DTC.getCurrentTime - H.byDeadlineM 5 leadershipScheduleDeadline "leadershipSchedule:next:error" $ do + H.byDeadlineM 5 leadershipScheduleDeadline $ do void $ H.execCli' execConfig [ "query", "leadership-schedule" , "--testnet-magic", show @Int testnetMagic