Skip to content
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
102 changes: 57 additions & 45 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,61 @@ let
} // args);
haskellPackages = buildHaskellPackages {};
profiledHaskellPackages = buildHaskellPackages { profiling = true; };
coveredHaskellPackages = buildHaskellPackages { coverage = true; };

getPackageChecks = mapAttrs (_: package: package.checks);

# Creates a development environment for Cabal builds or ghci
# sessions, with various build tools included.
mkShell = name: hp: hp.shellFor {
inherit name;
packages = ps: attrValues (selectProjectPackages ps);
buildInputs = (with self; [
jormungandr
jormungandr-cli
cardano-node
cardano-cli
cardano-address
cardano-tx
bech32
]) ++ (with pkgs; [
niv
pkgconfig
python3Packages.openapi-spec-validator
ruby
sqlite-interactive
yq
]) ++ attrValues hls;
tools = {
cabal = "3.2.0.0";
ghcid = "0.8.7";
hlint = "3.2";
lentil = "1.3.2.0";
stylish-haskell = "0.11.0.3";
weeder = "1.0.9";
};
CARDANO_NODE_CONFIGS = cardano-node.deployments;
meta.platforms = lib.platforms.unix;
shellHook = ''
setup_completion() {
local p
for p in $buildInputs; do
if [ -d "$p/share/bash-completion" ]; then
addToSearchPath XDG_DATA_DIRS "$p/share"
fi
done
}
setup_completion
'';
};

# Build latest release of haskell-language-server from github
hls = pkgs.callPackages ./nix/hls.nix {
compiler-nix-name = haskellPackages._config.compiler.nix-name;
};

self = {
inherit pkgs commonLib src haskellPackages profiledHaskellPackages;
inherit pkgs commonLib src haskellPackages profiledHaskellPackages coveredHaskellPackages;
# Jormungandr
inherit (jmPkgs) jormungandr jormungandr-cli;
# expose cardano-node, so daedalus can ship it without needing to pin cardano-node
Expand Down Expand Up @@ -101,9 +151,11 @@ let
};

# `tests` are the test suites which have been built.
tests = collectComponents "tests" isProjectPackage haskellPackages;
tests = collectComponents "tests" isProjectPackage coveredHaskellPackages;
# `checks` are the result of executing the tests.
checks = pkgs.recurseIntoAttrs (getPackageChecks (selectProjectPackages haskellPackages));
checks = pkgs.recurseIntoAttrs (getPackageChecks (selectProjectPackages coveredHaskellPackages));
# Combined project coverage report
inherit (coveredHaskellPackages) testCoverageReport;
# `benchmarks` are only built, not run.
benchmarks = collectComponents "benchmarks" isProjectPackage haskellPackages;

Expand All @@ -114,48 +166,8 @@ let
shelley = self.cardano-wallet;
});

shell = haskellPackages.shellFor {
name = "cardano-wallet-shell";
packages = ps: attrValues (selectProjectPackages ps);
buildInputs = (with self; [
jormungandr
jormungandr-cli
cardano-node
cardano-cli
cardano-address
cardano-tx
bech32
]) ++ (with pkgs; [
niv
pkgconfig
python3Packages.openapi-spec-validator
ruby
sqlite-interactive
yq
]);
tools = {
cabal = "3.2.0.0";
ghcid = "0.8.7";
ghcide = "0.2.0";
hlint = "3.1.6";
lentil = "1.3.2.0";
stylish-haskell = "0.11.0.0";
weeder = "1.0.9";
};
CARDANO_NODE_CONFIGS = cardano-node.deployments;
meta.platforms = lib.platforms.unix;
shellHook = ''
setup_completion() {
local p
for p in $buildInputs; do
if [ -d "$p/share/bash-completion" ]; then
addToSearchPath XDG_DATA_DIRS "$p/share"
fi
done
}
setup_completion
'';
};
shell = mkShell "cardano-wallet-shell" haskellPackages;
shell-prof = mkShell "cardano-wallet-shell-profiled" profiledHaskellPackages;
cabalShell = import ./nix/cabal-shell.nix { inherit pkgs; walletPackages = self; };
stackShell = import ./nix/stack-shell.nix { inherit pkgs; walletPackages = self; };

Expand Down
7 changes: 2 additions & 5 deletions lib/core/src/Cardano/Byron/Codec/Cbor.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- need this for {-# HLINT ... #-}; see https://github.com/ndmitchell/hlint#ignoring-hints
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
Expand Down Expand Up @@ -281,7 +278,7 @@ decodeTx = do
_ <- decodeEmptyAttributes
return (ins, outs)

{-# HLINT ignore decodeTxIn "Use <$>" #-}
{- HLINT ignore decodeTxIn "Use <$>" -}
decodeTxIn :: CBOR.Decoder s TxIn
decodeTxIn = do
_ <- CBOR.decodeListLenCanonicalOf 2
Expand All @@ -301,7 +298,7 @@ decodeTxIn = do
tx <- Hash <$> CBOR.decodeBytes
TxIn tx <$> CBOR.decodeWord32

{-# HLINT ignore decodeTxOut "Use <$>" #-}
{- HLINT ignore decodeTxOut "Use <$>" -}
decodeTxOut :: CBOR.Decoder s TxOut
decodeTxOut = do
_ <- CBOR.decodeListLenCanonicalOf 2
Expand Down
3 changes: 1 addition & 2 deletions lib/core/src/Cardano/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Redundant flip" #-}
{- HLINT ignore "Redundant flip" -}

-- |
-- Copyright: © 2018-2020 IOHK
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Pool/DB/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ mReadSettings = get #settings
-- `const` isn't more readable than lambdas. Our language is based on
-- lambda calculus and we shouldn't feel ashamed to use them. They also
-- have different strictness properties.
{-# HLINT ignore mPutSettings "Use const" #-}
{- HLINT ignore mPutSettings "Use const" -}
mPutSettings
:: Settings
-> ModelOp ()
Expand Down
3 changes: 1 addition & 2 deletions lib/core/src/Cardano/Pool/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Redundant flip" #-}
{- HLINT ignore "Redundant flip" -}

-- |
-- Copyright: © 2018-2020 IOHK
Expand Down
3 changes: 1 addition & 2 deletions lib/core/src/Cardano/Wallet/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Redundant flip" #-}
{- HLINT ignore "Redundant flip" -}

-- |
-- Copyright: © 2018-2020 IOHK
Expand Down
2 changes: 1 addition & 1 deletion lib/core/test/unit/Cardano/Byron/Codec/CborSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import qualified Data.ByteArray as BA
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BL

{-# ANN spec ("HLint: ignore Use head" :: String) #-}
{- HLINT ignore spec "Use head" -}

spec :: Spec
spec = do
Expand Down
4 changes: 2 additions & 2 deletions lib/core/test/unit/Cardano/Wallet/DB/StateMachine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ import qualified Test.QuickCheck as QC
import qualified Test.StateMachine.Types as QSM
import qualified Test.StateMachine.Types.Rank2 as Rank2

{-# ANN module ("HLint: ignore Unused LANGUAGE pragma" :: String) #-}
{- HLINT ignore "Unused LANGUAGE pragma" -}

{-------------------------------------------------------------------------------
Mock implementation
Expand Down Expand Up @@ -569,7 +569,7 @@ lockstep m@(Model _ ws) c (At resp) = Event
Generator
-------------------------------------------------------------------------------}

{-# ANN generator ("HLint: ignore Use ++" :: String) #-}
{- HLINT ignore generator "Use ++" -}
generator
:: forall s. (Arbitrary (Wallet s), GenState s)
=> Model s Symbolic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Test.QuickCheck.Monadic as QC

{-# ANN module ("HLint: ignore Use <$>" :: String) #-}
{- HLINT ignore "Use <$>" -}

spec :: Spec
spec = do
Expand Down
2 changes: 1 addition & 1 deletion lib/jormungandr/src/Cardano/Wallet/Jormungandr/Binary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ maxNumberOfOutputs = 254
-------------------------------------------------------------------------------}

-- Do-notation is favoured over applicative syntax for readability:
{-# ANN module ("HLint: ignore Use <$>" :: String) #-}
{- HLINT ignore "Use <$>" -}

data BlockHeader = BlockHeader
{ version :: Word16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ import qualified Cardano.Wallet.Jormungandr.Api.Client as Jormungandr
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8

{-# ANN spec ("HLint: ignore Use head" :: String) #-}
{- HLINT ignore spec "Use head" -}

spec :: Spec
spec = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

module Cardano.Pool.Jormungandr.MetricsSpec
( spec
Expand Down Expand Up @@ -177,7 +176,7 @@ prop_combineIsLeftBiased mStake_ mProd_ mPerf_ =
mStake = Map.mapKeys getLowEntropy mStake_
mProd = Map.mapKeys getLowEntropy mProd_
mPerf = Map.mapKeys getLowEntropy mPerf_
{-# HLINT ignore prop_combineIsLeftBiased "Use ||" #-}
{- HLINT ignore prop_combineIsLeftBiased "Use ||" -}

-- | A list of chunks of blocks to be served up by the mock network layer.
newtype RegistrationsTest = RegistrationsTest
Expand Down
3 changes: 2 additions & 1 deletion lib/launcher/test/unit/Cardano/LauncherSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ import Test.Hspec
import Test.Utils.Windows
( isWindows, pendingOnWine )

{-# ANN spec ("HLint: ignore Use head" :: String) #-}
{- HLINT ignore spec "Use head" -}

spec :: Spec
spec = beforeAll setupMockCommands $ do
it "Buildable Command" $ \MockCommands{..} -> do
Expand Down
2 changes: 1 addition & 1 deletion lib/shelley/bench/Restore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ benchmarksSeq _ w wid wname restoreTime = do
, walletOverview
}

{-# ANN bench_restoration ("HLint: ignore Use camelCase" :: String) #-}
{- HLINT ignore bench_restoration "Use camelCase" -}
bench_restoration
:: forall (n :: NetworkDiscriminant) (k :: Depth -> * -> *) s t results.
( IsOurs s Address
Expand Down
2 changes: 2 additions & 0 deletions lib/shelley/src/Cardano/Wallet/Shelley/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ import qualified Shelley.Spec.Ledger.Keys as SL
import qualified Shelley.Spec.Ledger.LedgerState as SL

{- HLINT ignore "Use readTVarIO" -}
{- HLINT ignore "Use newTVarIO" -}
{- HLINT ignore "Use newEmptyTMVarIO" -}

-- | Network layer cursor for Shelley. Mostly useless since the protocol itself is
-- stateful and the node's keep track of the associated connection's cursor.
Expand Down
31 changes: 27 additions & 4 deletions nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
, config ? {}
# Enable profiling
, profiling ? config.haskellNix.profiling or false
# Enable Haskell Program Coverage for cardano-wallet libraries and test suites.
, coverage ? config.haskellNix.coverage or false
# Project top-level source tree
, src
# GitHub PR number (when building on Hydra)
Expand All @@ -29,7 +31,7 @@ let
filterSubDir = subDir:
haskell.haskellLib.cleanSourceWith { inherit src subDir; };

pkgSet = haskell.mkStackPkgSet {
pkg-set = haskell.mkStackPkgSet {
inherit stack-pkgs;
modules = [
# Add source filtering to local packages
Expand Down Expand Up @@ -61,6 +63,21 @@ let
packages.text-class.flags.release = true;
}

(lib.optionalAttrs coverage {
# Enable Haskell Program Coverage for all local libraries and test suites.
packages.cardano-wallet.components.library.doCoverage = true;
packages.cardano-wallet-cli.components.library.doCoverage = true;
packages.cardano-wallet-core-integration.components.library.doCoverage = true;
packages.cardano-wallet-core.components.library.doCoverage = true;
packages.cardano-wallet-core.components.tests.unit.doCoverage = true;
packages.cardano-wallet-jormungandr.components.library.doCoverage = true;
packages.cardano-wallet-jormungandr.components.tests.unit.doCoverage = true;
packages.cardano-wallet-jormungandr.components.tests.jormungandr-integration.doCoverage = true;
packages.cardano-wallet-launcher.components.library.doCoverage = true;
packages.cardano-wallet-test-utils.components.library.doCoverage = true;
packages.text-class.components.library.doCoverage = true;
})

# Provide configuration and dependencies to cardano-wallet components
{
packages.cardano-wallet.components.tests = {
Expand Down Expand Up @@ -305,8 +322,14 @@ let
'';
};

proj = haskell.addProjectAndPackageAttrs {
inherit pkg-set;
inherit (pkg-set.config) hsPkgs;
};

in
pkgSet.config.hsPkgs // {
_config = pkgSet.config;
_roots = haskell.roots pkgSet.config.ghc;
proj.hsPkgs // {
_config = proj.pkg-set.config;
#_roots = haskell.roots proj.pkg-set.config.ghc;
testCoverageReport = proj.projectCoverageReport;
}
32 changes: 32 additions & 0 deletions nix/hls.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ haskell-nix, fetchFromGitHub, compiler-nix-name }:

let
hlsPkgs = haskell-nix.cabalProject {
src = fetchFromGitHub {
name = "haskell-language-server";
owner = "haskell";
repo = "haskell-language-server";
rev = "0.5.0";
sha256 = "0vkh5ff6l5wr4450xmbki3cfhlwf041fjaalnwmj7zskd72s9p7p";
fetchSubmodules = true;
};

# Fix source info of brittany dep
lookupSha256 = { location, tag, ... } : {
"https://github.com/bubba/brittany.git"."c59655f10d5ad295c2481537fc8abf0a297d9d1c" = "1rkk09f8750qykrmkqfqbh44dbx1p8aq1caznxxlw8zqfvx39cxl";
}."${location}"."${tag}";

# Use same GHC as the project
inherit compiler-nix-name;

# # Materialization voodoo (disabled for now).
# inherit index-state checkMaterialization;
# Invalidate and update if you change the version
# plan-sha256 = "144p19wpydc6c56f0zw5b7c17151n0cghimr9wd8rlhifymmky2h";
};

in
{
inherit (hlsPkgs.haskell-language-server.components.exes) haskell-language-server;
inherit (hlsPkgs.hie-bios.components.exes) hie-bios;
}
1 change: 0 additions & 1 deletion nix/pkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ in pkgs: super: with pkgs; {
environments = {
inherit (pkgs.commonLib.cardanoLib.environments)
mainnet
mainnet_candidate_4
staging
testnet
shelley_qa
Expand Down
Loading