Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit a2be15c

Browse files
authored
Merge pull request #3662 from input-output-hk/rvl/cabal-new-build
[DEVOPS-1061] Add support for cabal new-build
2 parents 8251c93 + 6a920f8 commit a2be15c

8 files changed

+165
-99
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Cabal & Stack
22
.stack-work/
33
*/dist
4+
dist-newstyle/
5+
.ghc.environment.*
6+
cabal.project.local
47

58
# From daedalus-bridge
69
node_modules/*

cabal.project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
packages:
2+
*/*.cabal
3+
*/test/*.cabal
4+
5+
-- not sure why the cabal solver wants to download and build a newer beam-sqlite
6+
constraints: beam-sqlite == 0.3.2.1
7+
-- allow-newer: all
8+
-- allow-older: all

docs/how-to/build-cardano-sl-and-daedalus-from-source-code.md

+39
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,45 @@ Run the building script:
167167
$ cd cardano-sl
168168
[~/cardano-sl]$ ./scripts/build/cardano-sl.sh
169169

170+
## `cabal new-build` and Nix (experimental, for developers)
171+
172+
This type of build gives you a multi-package project with incremental
173+
builds, where the all of the build dependencies (Haskell packages and
174+
system libraries) are downloaded from the binary cache and available
175+
in the shell.
176+
177+
See the previous section on how to set up the IOHK binary cache.
178+
179+
Before you start, install a recent version of `cabal` into your
180+
profile. The package set used by cardano-sl (nixpkgs 18.03) only has
181+
cabal 2.0.0.1 which doesn't work.
182+
183+
[nix-shell:~]$ nix-env -f channel:nixos-18.09 -iA pkgs.cabal-install
184+
185+
Enter the `nix-shell`:
186+
187+
[nix-shell:~/cardano-sl]$ nix-shell
188+
189+
Let cabal find its dependencies (already provided by the `nix-shell`):
190+
191+
[nix-shell:~/cardano-sl]$ cabal new-configure
192+
193+
After that, to build all cardano-sl packages:
194+
195+
[nix-shell:~/cardano-sl]$ cabal new-build all
196+
197+
To start a GHCi session for a component (wallet-new for example), run:
198+
199+
[nix-shell:~/cardano-sl]$ cabal new-repl cardano-sl-wallet-new
200+
201+
### Known issues
202+
203+
- `cabal-install` is not provided by the Nix shell environment. You
204+
have to install it yourself.
205+
- There needs to be a package version override in `cabal.project` for
206+
some unknown reason.
207+
208+
170209
## Daedalus Wallet
171210

172211
Let's proceed with building the wallet.

node/cardano-sl-node.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ test-suite property-tests
9191
, cardano-sl-infra
9292
, cardano-sl-networking
9393
, cardano-sl-util
94+
, cardano-sl-utxo
9495
, cardano-sl-wallet-new
9596
, constraints
9697
, containers
@@ -103,7 +104,6 @@ test-suite property-tests
103104
, safe-exceptions >= 0.1
104105
, text
105106
, universum >= 0.1.11
106-
, utxo
107107
, validation
108108
ghc-options:
109109
-threaded

pkgs/default.nix

+81-81
Original file line numberDiff line numberDiff line change
@@ -17128,6 +17128,7 @@ license = stdenv.lib.licenses.mit;
1712817128
, cardano-sl-infra
1712917129
, cardano-sl-networking
1713017130
, cardano-sl-util
17131+
, cardano-sl-utxo
1713117132
, cardano-sl-wallet-new
1713217133
, constraints
1713317134
, containers
@@ -17144,7 +17145,6 @@ license = stdenv.lib.licenses.mit;
1714417145
, stdenv
1714517146
, text
1714617147
, universum
17147-
, utxo
1714817148
, validation
1714917149
}:
1715017150
mkDerivation {
@@ -17184,6 +17184,7 @@ cardano-sl-db
1718417184
cardano-sl-infra
1718517185
cardano-sl-networking
1718617186
cardano-sl-util
17187+
cardano-sl-utxo
1718717188
cardano-sl-wallet-new
1718817189
constraints
1718917190
containers
@@ -17198,7 +17199,6 @@ reflection
1719817199
safe-exceptions
1719917200
text
1720017201
universum
17201-
utxo
1720217202
validation
1720317203
];
1720417204
doHaddock = false;
@@ -17662,6 +17662,82 @@ doHaddock = false;
1766217662
description = "Cardano SL - general utilities (tests)";
1766317663
license = stdenv.lib.licenses.mit;
1766417664

17665+
}) {};
17666+
"cardano-sl-utxo" = callPackage
17667+
({
17668+
mkDerivation
17669+
, base
17670+
, cardano-crypto
17671+
, cardano-sl
17672+
, cardano-sl-binary
17673+
, cardano-sl-chain
17674+
, cardano-sl-chain-test
17675+
, cardano-sl-client
17676+
, cardano-sl-core
17677+
, cardano-sl-core-test
17678+
, cardano-sl-crypto
17679+
, cardano-sl-crypto-test
17680+
, cardano-sl-db
17681+
, cardano-sl-util
17682+
, constraints
17683+
, containers
17684+
, cryptonite
17685+
, data-default
17686+
, formatting
17687+
, lens
17688+
, log-warper
17689+
, mtl
17690+
, QuickCheck
17691+
, reflection
17692+
, safe-exceptions
17693+
, safecopy
17694+
, serokell-util
17695+
, stdenv
17696+
, universum
17697+
, unordered-containers
17698+
, vector
17699+
}:
17700+
mkDerivation {
17701+
17702+
pname = "cardano-sl-utxo";
17703+
version = "0.1.0.0";
17704+
src = ./../utxo;
17705+
libraryHaskellDepends = [
17706+
base
17707+
cardano-crypto
17708+
cardano-sl
17709+
cardano-sl-binary
17710+
cardano-sl-chain
17711+
cardano-sl-chain-test
17712+
cardano-sl-client
17713+
cardano-sl-core
17714+
cardano-sl-core-test
17715+
cardano-sl-crypto
17716+
cardano-sl-crypto-test
17717+
cardano-sl-db
17718+
cardano-sl-util
17719+
constraints
17720+
containers
17721+
cryptonite
17722+
data-default
17723+
formatting
17724+
lens
17725+
log-warper
17726+
mtl
17727+
QuickCheck
17728+
reflection
17729+
safe-exceptions
17730+
safecopy
17731+
serokell-util
17732+
universum
17733+
unordered-containers
17734+
vector
17735+
];
17736+
doHaddock = false;
17737+
homepage = "https://github.com/input-output-hk/cardano-sl/#readme";
17738+
description = "Abstract definitions of UTxO based accounting";
17739+
license = stdenv.lib.licenses.mit;
17740+
1766517741
}) {};
1766617742
"cardano-sl-wallet" = callPackage
1766717743
({
@@ -17899,6 +17975,7 @@ license = stdenv.lib.licenses.mit;
1789917975
, cardano-sl-node-ipc
1790017976
, cardano-sl-util
1790117977
, cardano-sl-util-test
17978+
, cardano-sl-utxo
1790217979
, cardano-sl-wallet
1790317980
, cardano-sl-x509
1790417981
, cassava
@@ -17969,7 +18046,6 @@ license = stdenv.lib.licenses.mit;
1796918046
, unliftio
1797018047
, unliftio-core
1797118048
, unordered-containers
17972-
, utxo
1797318049
, vector
1797418050
, wai
1797518051
, wai-middleware-throttle
@@ -18018,6 +18094,7 @@ cardano-sl-infra
1801818094
cardano-sl-networking
1801918095
cardano-sl-node-ipc
1802018096
cardano-sl-util
18097+
cardano-sl-utxo
1802118098
cardano-sl-wallet
1802218099
cardano-sl-x509
1802318100
cereal
@@ -18073,7 +18150,6 @@ universum
1807318150
unliftio
1807418151
unliftio-core
1807518152
unordered-containers
18076-
utxo
1807718153
vector
1807818154
wai
1807918155
wai-middleware-throttle
@@ -18134,6 +18210,7 @@ cardano-sl-crypto-test
1813418210
cardano-sl-db
1813518211
cardano-sl-util
1813618212
cardano-sl-util-test
18213+
cardano-sl-utxo
1813718214
cardano-sl-wallet
1813818215
cereal
1813918216
conduit
@@ -18170,7 +18247,6 @@ time
1817018247
time-units
1817118248
universum
1817218249
unordered-containers
18173-
utxo
1817418250
vector
1817518251
];
1817618252
benchmarkHaskellDepends = [
@@ -83006,82 +83082,6 @@ doCheck = false;
8300683082
description = "Various small helper functions for Lists, Maybes, Tuples, Functions";
8300783083
license = stdenv.lib.licenses.bsd3;
8300883084

83009-
}) {};
83010-
"utxo" = callPackage
83011-
({
83012-
mkDerivation
83013-
, base
83014-
, cardano-crypto
83015-
, cardano-sl
83016-
, cardano-sl-binary
83017-
, cardano-sl-chain
83018-
, cardano-sl-chain-test
83019-
, cardano-sl-client
83020-
, cardano-sl-core
83021-
, cardano-sl-core-test
83022-
, cardano-sl-crypto
83023-
, cardano-sl-crypto-test
83024-
, cardano-sl-db
83025-
, cardano-sl-util
83026-
, constraints
83027-
, containers
83028-
, cryptonite
83029-
, data-default
83030-
, formatting
83031-
, lens
83032-
, log-warper
83033-
, mtl
83034-
, QuickCheck
83035-
, reflection
83036-
, safe-exceptions
83037-
, safecopy
83038-
, serokell-util
83039-
, stdenv
83040-
, universum
83041-
, unordered-containers
83042-
, vector
83043-
}:
83044-
mkDerivation {
83045-
83046-
pname = "utxo";
83047-
version = "0.1.0.0";
83048-
src = ./../utxo;
83049-
libraryHaskellDepends = [
83050-
base
83051-
cardano-crypto
83052-
cardano-sl
83053-
cardano-sl-binary
83054-
cardano-sl-chain
83055-
cardano-sl-chain-test
83056-
cardano-sl-client
83057-
cardano-sl-core
83058-
cardano-sl-core-test
83059-
cardano-sl-crypto
83060-
cardano-sl-crypto-test
83061-
cardano-sl-db
83062-
cardano-sl-util
83063-
constraints
83064-
containers
83065-
cryptonite
83066-
data-default
83067-
formatting
83068-
lens
83069-
log-warper
83070-
mtl
83071-
QuickCheck
83072-
reflection
83073-
safe-exceptions
83074-
safecopy
83075-
serokell-util
83076-
universum
83077-
unordered-containers
83078-
vector
83079-
];
83080-
doHaddock = false;
83081-
homepage = "https://github.com/input-output-hk/cardano-sl/#readme";
83082-
description = "Abstract definitions of UTxO based accounting";
83083-
license = stdenv.lib.licenses.mit;
83084-
8308583085
}) {};
8308683086
"uuid" = callPackage
8308783087
({

shell.nix

+30-14
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,40 @@ in
1616
}:
1717
with pkgs;
1818
let
19-
hsPkgs = haskell.packages.ghc822;
19+
getCardanoSLDeps = with lib;
20+
ps: filter (drv: !(localLib.isCardanoSL drv.name))
21+
(concatMap haskell.lib.getHaskellBuildInputs
22+
(attrValues (filterAttrs isWantedDep ps)));
23+
isWantedDep = name: drv: localLib.isCardanoSL name && !(drv ? "gitrev");
24+
ghc = cardanoPkgs.ghc.withPackages getCardanoSLDeps;
25+
26+
stackDeps = [
27+
zlib openssh autoreconfHook openssl
28+
gmp rocksdb git bsdiff ncurses lzma
29+
perl bash
30+
];
31+
# TODO: add cabal-install (2.0.0.1 won't work)
32+
devTools = [ hlint cardanoPkgs.stylish-haskell ];
33+
2034
cardanoSL = haskell.lib.buildStackProject {
21-
name = "cardano-sl-env";
22-
ghc = hsPkgs.ghc;
23-
buildInputs = [
24-
zlib openssh autoreconfHook openssl
25-
gmp rocksdb git bsdiff ncurses
26-
hsPkgs.happy hsPkgs.cpphs lzma
27-
perl bash
28-
cardanoPkgs.stylish-haskell
29-
hlint
30-
# cabal-install and stack pull in lots of dependencies on OSX so skip them
31-
# See https://github.com/NixOS/nixpkgs/issues/21200
32-
] ++ (lib.optionals stdenv.isLinux [ cabal-install stack ])
33-
++ (lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa CoreServices libcxx libiconv ]));
35+
inherit ghc;
36+
name = "cardano-sl-env";
37+
38+
buildInputs = devTools ++ stackDeps
39+
# cabal-install and stack pull in lots of dependencies on OSX so skip them
40+
# See https://github.com/NixOS/nixpkgs/issues/21200
41+
++ (lib.optionals stdenv.isLinux [ stack ])
42+
++ (lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa CoreServices libcxx libiconv ]));
43+
44+
shellHook = lib.optionalString lib.inNixShell ''
45+
eval "$(egrep ^export ${ghc}/bin/ghc)"
46+
export PATH=${ghc}/bin:$PATH
47+
'';
48+
3449
phases = ["nobuildPhase"];
3550
nobuildPhase = "mkdir -p $out";
3651
};
52+
3753
fixStylishHaskell = stdenv.mkDerivation {
3854
name = "fix-stylish-haskell";
3955
buildInputs = [ cardanoPkgs.stylish-haskell git ];

utxo/utxo.cabal renamed to utxo/cardano-sl-utxo.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: utxo
1+
name: cardano-sl-utxo
22
version: 0.1.0.0
33
synopsis: Abstract definitions of UTxO based accounting
44
-- description:

0 commit comments

Comments
 (0)