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

[ADP-3226] Update indexState in haskell.nix #4843

Merged
merged 7 commits into from
Dec 17, 2024
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
1 change: 0 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ steps:
- linux-nix
steps:
- label: Nix Build (linux)
# Check whether regenerate.sh was applied when it had to be applied.
commands:
- nix build .#cardano-wallet
agents:
Expand Down
18 changes: 11 additions & 7 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
-- Updating this file
--
-- This file is the canonical source of dependencies.
-- To generate the Nix packages, use ./nix/regenerate.sh
--
-- -----------------------------------------------------------------------------
-- How to use with the nix shell
Expand Down Expand Up @@ -170,6 +169,7 @@ allow-newer:
async-timer:unliftio-core
, servant-openapi3:*
, katip:Win32
, ekg-wai:time

constraints:
base >= 4.18.2.0 && < 5
Expand All @@ -178,6 +178,13 @@ constraints:

, bech32 >= 1.1.7

-- Force newer version of `lobemo-backend-ekg` here,
-- because older versions depend on `snap-server`,
-- which in turns fails to link on linux musl
-- due to some missing `sendfile64` hack.
-- (We use linux musl to get statically linked binaries.)
, lobemo-backend-ekg >= 0.2.0.0

-- lower versions of katip won't build with the Win32-2.12.0.1
-- which is shipped with the ghc-9.2.8
, katip >= 0.8.7.4
Expand All @@ -186,10 +193,10 @@ constraints:
-- Cardano Node dependencies:
, io-classes >= 1.4
, io-classes -asserts

, cardano-ledger-api ==1.9.4.0

, ouroboros-network == 0.17.1.2
, cardano-ledger-api ^>= 1.9

, ouroboros-network ^>= 0.17


-- Related to: https://github.com/haskell/cabal/issues/8554
Expand Down Expand Up @@ -257,9 +264,6 @@ package cardano-wallet
package cardano-wallet-api
tests: True

package cardano-wallet-cli
tests: True

package cardano-wallet-launcher
tests: True

Expand Down
22 changes: 12 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@
inherit dockerImage;
inherit (config) dockerHubRepoName;
};
inherit (pkgs) checkCabalProject;
} // (lib.optionalAttrs buildPlatform.isLinux {
nixosTests = import ./nix/nixos/tests {
inherit pkgs;
Expand All @@ -436,15 +435,18 @@
};

ci.benchmarks =
packages.benchmarks.cardano-wallet-benchmarks //
packages.benchmarks.cardano-wallet-blackbox-benchmarks // {
all = pkgs.releaseTools.aggregate {
name = "cardano-wallet-benchmarks";
meta.description = "Build all benchmarks";
constituents =
lib.collect lib.isDerivation packages.benchmarks;
};
};
let
collectedBenchmarks =
lib.concatMapAttrs (_n: v: v) packages.benchmarks;
in
collectedBenchmarks // {
all = pkgs.releaseTools.aggregate {
name = "cardano-wallet-benchmarks";
meta.description = "Build all benchmarks";
constituents =
lib.collect lib.isDerivation collectedBenchmarks;
};
};
ci.artifacts = mkReleaseArtifacts walletProject // {
dockerImage = packages.dockerImage;
};
Expand Down
49 changes: 1 addition & 48 deletions nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
filter = lib.cleanSourceFilter;
};

indexState = "2024-08-08T00:00:00Z";
indexState = "2024-08-20T21:35:22Z";

localClusterConfigs = config.src + /lib/local-cluster/test/data/cluster-configs;

Expand Down Expand Up @@ -140,7 +140,6 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
curlFull
jq
yq
nixWrapped
mdbook
haskellPackages.fourmolu
haskellPackages.ghcid
Expand All @@ -164,10 +163,6 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
[
{
packages = lib.genAttrs projectPackages (name: {
# Mark package as local non-dep in the nix-shell.
# fixme: Haskell.nix should set it
package.isProject = true;

# Enable release flag (optimization and -Werror)
flags.release = true;

Expand All @@ -185,16 +180,6 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
{
reinstallableLibGhc = true;

# These are here to make `stackProject` vs `cabalProject` `nix-diff` cleaner
# TODO remove
packages.entropy.components.setup.doExactConfig = true;
packages.prettyprinter-configurable.components.setup.doExactConfig = true;
packages.pretty-simple.components.setup.doExactConfig = true;
packages.wai-logger.components.setup.doExactConfig = true;
packages.openapi3.components.setup.doExactConfig = true;
packages.servant-openapi3.components.setup.doExactConfig = true;
packages.system-filepath.components.setup.doExactConfig = true;

packages.cardano-wallet-unit.components.tests = {
unit.build-tools = cardanoNodeExes;
unit.preCheck = noCacheTestFailuresCookie + ''
Expand Down Expand Up @@ -286,26 +271,6 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
packages.cardano-wallet.components.exes.cardano-wallet.postInstall = optparseCompletionPostInstall + setGitRevPostInstall + rewriteLibsPostInstall + stripBinariesPostInstall;
})

({ config, ... }:
let
setGitRevPostInstall = setGitRevPostInstall' config.packages.cardano-node.src.rev;
in
{
# Add shell completions for tools.
packages.cardano-cli.components.exes.cardano-cli.postInstall = optparseCompletionPostInstall + setGitRevPostInstall;
packages.cardano-node.components.exes.cardano-node.postInstall = optparseCompletionPostInstall + setGitRevPostInstall;
packages.cardano-addresses-cli.components.exes.cardano-address.postInstall = optparseCompletionPostInstall;
packages.bech32.components.exes.bech32.postInstall = optparseCompletionPostInstall;
})

# Provide the git revision for cardano-addresses
({ config, ... }:
{
packages.cardano-addresses-cli.components.library.preBuild = ''
export GITREV=${config.hsPkgs.cardano-addresses-cli.src.rev}
'';
})

# Provide the swagger file in an environment variable for
# tests because it is located outside of the Cabal package
# source tree.
Expand All @@ -319,7 +284,6 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
# Use our forked libsodium from iohk-nix crypto overlay.
packages.plutus-tx.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ];
packages.byron-spec-ledger.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ];
packages.cardano-wallet-cli.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ];
packages.cardano-crypto-praos.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ];
packages.cardano-crypto-class.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 pkgs.libblst ] ];
})
Expand All @@ -331,13 +295,6 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
# 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;

# Avoid this error on the windows build:
# Wrap.hsc:96:10: fatal error: regex.h: No such file or directory
packages.regex-posix.flags._regex-posix-clib = stdenv.hostPlatform.isWindows;

# Lets us put the pretty-simple tool in shell.nix.
packages.pretty-simple.flags.buildexe = true;
}
Expand Down Expand Up @@ -371,10 +328,6 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [
packages.cardano-wallet-benchmarks.components.benchmarks.db = fullyStaticOptions;
packages.cardano-wallet-launcher.components.tests.unit = fullyStaticOptions;

# systemd can't be statically linked - disable lobemo-scribe-journal
packages.cardano-config.flags.systemd = false;
packages.cardano-node.flags.systemd = false;

# Haddock not working for cross builds and is not needed anyway
doHaddock = false;
}
Expand Down
3 changes: 2 additions & 1 deletion nix/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ lib
rec {
# Imports from nixpkgs.lib
inherit (lib) filterAttrsRecursive recursiveUpdate collect
optionalAttrs mapAttrs isDerivation fileset;
optionalAttrs mapAttrs isDerivation fileset
concatMapAttrs;

/* Convert versions string from Cabal (YYYY.M.D)
to git tag format (vYYYY-MM-DD).
Expand Down
13 changes: 7 additions & 6 deletions nix/overlays/common-lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ in {
cardanoWalletLib = {

# Retrieve the list of local project packages by
# filtering the set of *all* packages by their homepage.
projectPackageList = lib.attrNames (lib.filterAttrs
(_: p: p != null
&& haskellLib.isLocalPackage p.package
&& p.package.homepage == "https://github.com/cardano-foundation/cardano-wallet")
cardanoWalletHaskellProject.pkg-set.config.packages);
# using the haskell.nix selectProjectPackages function.
projectPackageList =
let
project = haskellLib.selectProjectPackages cardanoWalletHaskellProject.hsPkgs;
names = map (key: (builtins.getAttr key project).identifier.name) (builtins.attrNames project);
in
lib.lists.unique names;

};
}
2 changes: 1 addition & 1 deletion nix/project-package-list.nix
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ "address-derivation-discovery" "cardano-api-extra" "cardano-balance-tx" "cardano-coin-selection" "cardano-numeric" "cardano-wallet" "cardano-wallet-api" "cardano-wallet-benchmarks" "cardano-wallet-blackbox-benchmarks" "cardano-wallet-integration" "cardano-wallet-launcher" "cardano-wallet-network-layer" "cardano-wallet-primitive" "cardano-wallet-read" "cardano-wallet-secrets" "cardano-wallet-test-utils" "cardano-wallet-unit" "customer-deposit-wallet" "delta-chain" "delta-store" "delta-table" "delta-types" "faucet" "local-cluster" "text-class" "wai-middleware-logging" ]
[ "address-derivation-discovery" "cardano-api-extra" "cardano-balance-tx" "cardano-coin-selection" "cardano-numeric" "cardano-wallet" "cardano-wallet-api" "cardano-wallet-application-extras" "cardano-wallet-benchmarks" "cardano-wallet-blackbox-benchmarks" "cardano-wallet-buildkite" "cardano-wallet-e2e" "cardano-wallet-exe" "cardano-wallet-integration" "cardano-wallet-launcher" "cardano-wallet-network-layer" "cardano-wallet-primitive" "cardano-wallet-secrets" "cardano-wallet-test-utils" "cardano-wallet-ui" "cardano-wallet-unit" "crypto-primitives" "customer-deposit-wallet" "delta-chain" "delta-store" "delta-table" "delta-types" "faucet" "iohk-monitoring-extra" "local-cluster" "std-gen-seed" "temporary-extra" "text-class" "wai-middleware-logging" ]
3 changes: 0 additions & 3 deletions nix/regenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ set -euo pipefail

cd $(dirname "$0")/..

# Regenerate --sha256 hashes in cabal.project
nix build .#checkCabalProject -o check-cabal-project.sh && ./check-cabal-project.sh
Comment on lines -7 to -8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Don't we want/need this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we mistype a hash in the cabal.project and direnv reload we get

direnv: loading ~/IOHK/cardano-wallet/.envrc
direnv: using flake
warning: Git tree '/Users/anviking/IOHK/cardano-wallet' is dirty
warning: ignoring the client-specified setting 'system', because it is a restricted setting and you are not a trusted user
warning: ignoring the client-specified setting 'system', because it is a restricted setting and you are not a trusted user
copying '/nix/store/lnwcc18q3mhx7saikwp1v93cib179w91-source' to the storedirenv: ([/opt/homebrew/bin/direnv export fish]) is taking a while to execute. Use CTRL-C to give up.
error: hash mismatch in fixed-output derivation '/nix/store/514wdhm14ymi53aayd85qbqfzys4bsd1-cardano-wallet-agda-f3479b5.drv':
         specified: sha256-fx5hsiOJZYuo37YIMTXUWcjqtigLNvT/3Yn/wOuZpgE=
            got:    sha256-fx5hsiOJZYuo37YIMTXUWcjqtigLNvT/3Yn/wOuZpoE=
error: 1 dependencies of derivation '/nix/store/xpg5g53xkjxx3snl3zvrgbi9l9q2ky2p-source-repository-package.drv' failed to build
error:
       … while evaluating the attribute 'shell'
         at /nix/store/wzhjzixv6w1x664vhsajrckalkhgr588-source/overlays/haskell.nix:849:13:
          848|             # Default shell
          849|             shell = shellFor rawProject.args.shell;
             |             ^
          850|while evaluating the attribute 'hsPkgs.shellFor'
         at /nix/store/wzhjzixv6w1x664vhsajrckalkhgr588-source/overlays/haskell.nix:693:44:
          692|               project = addProjectAndPackageAttrs rec {
          693|                   inherit (pkg-set.config) hsPkgs;
             |                                            ^
          694|                   inherit pkg-set;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: 1 dependencies of derivation '/nix/store/r4rw99sfibcayr3318mfhv74ijmw8y0d-cardano-wallet-plan-to-nix-pkgs.drv' failed to build

Copy link
Contributor Author

@HeinrichApfelmus HeinrichApfelmus Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want/need this?

Automatically fetching the --sha256 hashes was a more pressing issue at a time when CHaP did not yet exist, and we imported all Cardano dependencies via source-repository-package stanzas. Today, I think the cost of maintaining that automation is higher than manually adding --sha256 hashes for the few repositories that we do import in this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the cost of maintaining that automation is higher than manually adding

We can't just keep the inherit (pkgs) checkCabalProject line + this call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not — the checkCabalProject is actually provided by the iohkNix input (which adds it to pkgs via the overlay mechanism), which has bitrotted to the point where importing it breaks. See also input-output-hk/iohk-nix#589 .


# Regenerate the list of the project packages:
nix eval .#pkgs.cardanoWalletLib.projectPackageList > nix/project-package-list.nix.new
mv nix/project-package-list.nix.new nix/project-package-list.nix
Loading