Skip to content

Commit e762922

Browse files
committed
Make nix-shells functionnal.
1 parent 19321aa commit e762922

File tree

8 files changed

+140
-105
lines changed

8 files changed

+140
-105
lines changed

.buildkite/pipeline.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
steps:
2-
#- label: 'stack rebuild'
3-
# env:
4-
# STACK_ROOT: "/build/cardano-node.stack"
5-
# command:
6-
# - "rm -rf /build/cardano-node"
7-
# - "cp -R . /build/cardano-node"
8-
# - "cd /build/cardano-node"
9-
# - "nix-build scripts/buildkite -o stack-rebuild"
10-
# - "./stack-rebuild"
11-
# agents:
12-
# system: x86_64-linux
2+
- label: 'stack rebuild'
3+
env:
4+
STACK_ROOT: "/build/cardano-node.stack"
5+
command:
6+
- "rm -rf /build/cardano-node"
7+
- "cp -R . /build/cardano-node"
8+
- "cd /build/cardano-node"
9+
- "nix-build scripts/buildkite -o stack-rebuild"
10+
- "./stack-rebuild"
11+
agents:
12+
system: x86_64-linux
1313

1414
- label: 'check-cabal-project'
1515
command: 'nix-build lib.nix -A iohkNix.checkCabalProject -o check-cabal-project.sh && ./check-cabal-project.sh'
1616
agents:
1717
system: x86_64-linux
1818

19+
# FIXME, waiting for https://github.com/input-output-hk/haskell.nix/pull/426
1920
# - label: 'release.nix'
2021
# command: 'nix-build -A check-hydra -o check-hydra.sh && ./check-hydra.sh'
2122
# agents:

cardano-config/cardano-config.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ library
2020
Cardano.Config.Topology
2121
Cardano.Config.Types
2222

23-
build-depends: base >=4.12 && <4.13
23+
build-depends: base >=4.12 && <5
2424
, aeson
2525
, async
2626
, bytestring

default.nix

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{ system ? builtins.currentSystem
22
, crossSystem ? null
33
, config ? {}
4+
, sourcesOverride ? {}
45
, profiling ? false
56
, commonLib ? import ./lib.nix { inherit system crossSystem config profiling; }
67
, pkgs ? commonLib.pkgs
@@ -12,7 +13,7 @@
1213

1314
let
1415
lib = commonLib.pkgs.lib;
15-
inherit (commonLib) environments haskellPackages;
16+
inherit (commonLib) environments haskellPackages niv;
1617
cardano-node = haskellPackages.cardano-node.components.exes.cardano-node;
1718

1819
scripts = commonLib.pkgs.callPackage ./nix/scripts.nix {
@@ -42,26 +43,36 @@ let
4243

4344
shell = haskellPackages.shellFor {
4445

45-
#packages = ps: with ps; [
46-
# haskellPackages.cardano-node
47-
# haskellPackages.cardano-config
48-
#];
46+
47+
packages = ps: with ps; [
48+
ps.cardano-node
49+
ps.cardano-config
50+
# in theory we should only have the above two packages (or better, they should be auto-detected),
51+
# but due to source-repository-package declarations being considered as local packages by cabal, we need the following packages as well.
52+
# cf. https://github.com/haskell/cabal/issues/6249 and https://github.com/haskell/cabal/issues/5444
53+
ps.cardano-sl-x509
54+
ps.ekg-prometheus-adapter
55+
ps.ouroboros-consensus
56+
ps.ouroboros-network
57+
];
4958

5059
# Builds a Hoogle documentation index of all dependencies,
5160
# and provides a "hoogle" command to search the index.
5261
inherit withHoogle;
5362

5463
# You might want some extra tools in the shell (optional).
55-
buildInputs = (with haskellPackages; [
56-
#weeder.components.exes.weeder
57-
#hlint.components.exes.hlint
58-
#cabal-install.components.exes.cabal
59-
#ghcid.components.exes.ghcid
60-
]) ++ (with pkgs; [
64+
buildInputs = with pkgs; [
65+
cabal-install
66+
ghcid
67+
hlint
68+
pkgs.haskellPackages.weeder
69+
nix
70+
niv
6171
pkgconfig
6272
sqlite-interactive
6373
tmux
64-
]);
74+
git
75+
];
6576

6677
# Prevents cabal from choosing alternate plans, so that
6778
# *all* dependencies are provided by Nix.

lib.nix

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,36 @@
22
, crossSystem ? null
33
, config ? {}
44
, overlays ? []
5+
, sourcesOverride ? {}
56
, profiling ? false
67
}:
78

89
let
9-
sources = import ./nix/sources.nix;
10+
# use default stable nixpkgs from iohk-nix instead of our own:
11+
sources = removeAttrs (import ./nix/sources.nix) [ "nixpkgs" ] // sourcesOverride;
1012
iohkNix = import sources.iohk-nix {
13+
inherit config system crossSystem;
1114
sourcesOverride = sources;
15+
nixpkgsOverlays = overlays;
1216
};
13-
haskellNix = import sources."haskell.nix";
14-
args = haskellNix // {
15-
inherit system crossSystem;
16-
overlays = (haskellNix.overlays or []) ++ overlays;
17-
config = (haskellNix.config or {}) // config;
18-
};
19-
nixpkgs = import sources.nixpkgs;
20-
pkgs = nixpkgs args;
17+
pkgs = iohkNix.pkgs;
2118
haskellPackages = import ./nix/pkgs.nix {
2219
inherit pkgs profiling;
2320
src = ./.;
2421
};
2522
# TODO: add haskellPackages and fix svclib
2623
svcLib = import ./nix/svclib.nix { inherit pkgs; cardano-node-packages = haskellPackages.cardano-node.components.exes; };
2724
lib = pkgs.lib;
28-
niv = (import sources.niv {}).niv;
2925
isCardanoNode = with lib; package:
3026
(package.isHaskell or false) &&
31-
((hasPrefix "cardano-node" package.identifier.name) ||
32-
(elem package.identifier.name [ "text-class" "bech32" ]));
33-
filterCardanoPackages = pkgs.lib.filterAttrs (_: package: isCardanoNode package);
27+
((hasPrefix "cardano-node" package.identifier.name) ||
28+
(elem package.identifier.name [ "text-class" "bech32" ]));
29+
filterCardanoPackages = pkgs.lib.filterAttrs (_: isCardanoNode);
3430
getPackageChecks = pkgs.lib.mapAttrs (_: package: package.checks);
3531
in lib // iohkNix.cardanoLib // {
3632
inherit (pkgs.haskell-nix.haskellLib) collectComponents;
33+
inherit (iohkNix) niv;
3734
inherit
38-
niv
3935
sources
4036
haskellPackages
4137
pkgs

nix/pkgs.nix

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,63 +20,63 @@ let
2020
hasPrefix (toString origSrc + toString dir) path;
2121
} + dir;
2222

23-
recRecurseIntoAttrs = with pkgs; pred: x: if pred x then recurseIntoAttrs (lib.mapAttrs (n: v: if n == "buildPackages" then v else recRecurseIntoAttrs pred v) x) else x;
24-
pkgSet = recRecurseIntoAttrs (x: with pkgs; lib.isAttrs x && !lib.isDerivation x)
25-
# we are only intersted in listing the project packages
26-
(pkgs.lib.filterAttrs (with pkgs.haskell-nix.haskellLib; (n: p: p != null && (isLocalPackage p && isProjectPackage p) || n == "shellFor"))
27-
# from our project which is based on a cabal project.
28-
(pkgs.haskell-nix.cabalProject {
29-
src = pkgs.haskell-nix.haskellLib.cleanGit { inherit src; };
30-
ghc = pkgs.buildPackages.haskell-nix.compiler.${haskellCompiler};
31-
modules = [
32-
# Allow reinstallation of Win32
33-
{ nonReinstallablePkgs =
34-
[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
35-
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
36-
# ghcjs custom packages
37-
"ghcjs-prim" "ghcjs-th"
38-
"ghc-boot"
39-
"ghc" "array" "binary" "bytestring" "containers"
40-
"filepath" "ghc-boot" "ghc-compact" "ghc-prim"
41-
# "ghci" "haskeline"
42-
"hpc"
43-
"mtl" "parsec" "text" "transformers"
44-
"xhtml"
45-
# "stm" "terminfo"
46-
];
47-
}
48-
{
49-
# Packages we wish to ignore version bounds of.
50-
# This is similar to jailbreakCabal, however it
51-
# does not require any messing with cabal files.
52-
#doCheck = false;
53-
packages.katip.doExactConfig = true;
54-
packages.ekg.components.library.enableSeparateDataOutput = true;
55-
packages.cardano-node.configureFlags = [ "--ghc-option=-Werror" ];
56-
packages.cardano-node.doCheck = true;
57-
packages.cardano-config.configureFlags = [ "--ghc-option=-Werror" ];
58-
packages.cardano-config.doCheck = true;
59-
enableLibraryProfiling = profiling;
60-
}
61-
(pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isWindows {
62-
# Disable cabal-doctest tests by turning off custom setups
63-
packages.comonad.package.buildType = pkgs.lib.mkForce "Simple";
64-
packages.distributive.package.buildType = pkgs.lib.mkForce "Simple";
65-
packages.lens.package.buildType = pkgs.lib.mkForce "Simple";
66-
packages.nonempty-vector.package.buildType = pkgs.lib.mkForce "Simple";
67-
packages.semigroupoids.package.buildType = pkgs.lib.mkForce "Simple";
23+
pkg-set = pkgs.haskell-nix.cabalProject {
24+
src = pkgs.haskell-nix.haskellLib.cleanGit { inherit src; };
25+
ghc = pkgs.buildPackages.haskell-nix.compiler.${haskellCompiler};
26+
modules = [
6827

69-
# Make sure we use a buildPackages version of happy
70-
packages.pretty-show.components.library.build-tools = [ pkgs.buildPackages.haskell-nix.haskellPackages.happy ];
28+
# Allow reinstallation of Win32
29+
{ nonReinstallablePkgs =
30+
[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
31+
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
32+
# ghcjs custom packages
33+
"ghcjs-prim" "ghcjs-th"
34+
"ghc-boot"
35+
"ghc" "array" "binary" "bytestring" "containers"
36+
"filepath" "ghc-boot" "ghc-compact" "ghc-prim"
37+
# "ghci" "haskeline"
38+
"hpc"
39+
"mtl" "parsec" "text" "transformers"
40+
"xhtml"
41+
# "stm" "terminfo"
42+
];
43+
}
44+
{
45+
# Packages we wish to ignore version bounds of.
46+
# This is similar to jailbreakCabal, however it
47+
# does not require any messing with cabal files.
48+
packages.katip.doExactConfig = true;
7149

72-
# Remove hsc2hs build-tool dependencies (suitable version will be available as part of the ghc derivation)
73-
packages.Win32.components.library.build-tools = pkgs.lib.mkForce [];
74-
packages.terminal-size.components.library.build-tools = pkgs.lib.mkForce [];
75-
packages.network.components.library.build-tools = pkgs.lib.mkForce [];
76-
})
77-
];
78-
# TODO add flags to packages (like cs-ledger) so we can turn off tests that will
79-
# not build for windows on a per package bases (rather than using --disable-tests).
80-
configureArgs = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isWindows "--disable-tests";
81-
}));
82-
in pkgSet
50+
# split data output for ekg to reduce closure size
51+
packages.ekg.components.library.enableSeparateDataOutput = true;
52+
packages.cardano-node.configureFlags = [ "--ghc-option=-Werror" ];
53+
packages.cardano-config.configureFlags = [ "--ghc-option=-Werror" ];
54+
enableLibraryProfiling = profiling;
55+
56+
# some packages are missing identifier.name:
57+
packages.Win32.package.identifier.name = "Win32";
58+
packages.file-embed-lzma.package.identifier.name = "file-embed-lzma";
59+
packages.singletons.package.identifier.name = "singletons";
60+
}
61+
(pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isWindows {
62+
# Disable cabal-doctest tests by turning off custom setups
63+
packages.comonad.package.buildType = pkgs.lib.mkForce "Simple";
64+
packages.distributive.package.buildType = pkgs.lib.mkForce "Simple";
65+
packages.lens.package.buildType = pkgs.lib.mkForce "Simple";
66+
packages.nonempty-vector.package.buildType = pkgs.lib.mkForce "Simple";
67+
packages.semigroupoids.package.buildType = pkgs.lib.mkForce "Simple";
68+
69+
# Make sure we use a buildPackages version of happy
70+
packages.pretty-show.components.library.build-tools = [ pkgs.buildPackages.haskell-nix.haskellPackages.happy ];
71+
72+
# Remove hsc2hs build-tool dependencies (suitable version will be available as part of the ghc derivation)
73+
packages.Win32.components.library.build-tools = pkgs.lib.mkForce [];
74+
packages.terminal-size.components.library.build-tools = pkgs.lib.mkForce [];
75+
packages.network.components.library.build-tools = pkgs.lib.mkForce [];
76+
})
77+
];
78+
# TODO add flags to packages (like cs-ledger) so we can turn off tests that will
79+
# not build for windows on a per package bases (rather than using --disable-tests).
80+
configureArgs = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isWindows "--disable-tests";
81+
};
82+
in pkg-set

nix/sources.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@
6060
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
6161
},
6262
"iohk-nix": {
63-
"branch": "master",
63+
"branch": "update-nixpkgs-haskell-nix",
6464
"description": "nix scripts shared across projects",
6565
"homepage": null,
6666
"owner": "input-output-hk",
6767
"repo": "iohk-nix",
68-
"rev": "40fc58f0f1cb0f9de24d8df3144a8cd8f2e3a775",
69-
"sha256": "1h3d1gmjfxbwrdszj1ciqlbn646fy687w940fs4gx2bc12j39acb",
68+
"rev": "f4a09e460e344c12cdf30676c4a673c44f991f8b",
69+
"sha256": "0jlfyhlnz9gv3n7f75y0glhmywl362brfpbdmimjglnsmxxadvgc",
7070
"type": "tarball",
71-
"url": "https://github.com/input-output-hk/iohk-nix/archive/40fc58f0f1cb0f9de24d8df3144a8cd8f2e3a775.tar.gz",
71+
"url": "https://github.com/input-output-hk/iohk-nix/archive/f4a09e460e344c12cdf30676c4a673c44f991f8b.tar.gz",
7272
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
7373
},
7474
"niv": {

nix/stack-shell.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
with import ../lib.nix {};
3+
4+
pkgs.haskell.lib.buildStackProject {
5+
name = "cardano-node-stack-env";
6+
buildInputs = with pkgs; [ zlib openssl gmp libffi git systemd haskellPackages.happy ];
7+
ghc = (import ../shell.nix {}).ghc;
8+
}

stack.yaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
resolver: https://github.com/raw/input-output-hk/cardano-prelude/00487726c4bc21b4744e59d913334ebfeac7d68e/snapshot.yaml
1+
resolver: lts-14.22
2+
compiler: ghc-8.6.5
23

34
packages:
45
- cardano-config
@@ -8,7 +9,25 @@ ghc-options:
89
cardano-config: -Wall -fwarn-redundant-constraints
910
cardano-node: -Wall -fwarn-redundant-constraints
1011

12+
allow-newer: true
13+
1114
extra-deps:
15+
- git: https://github.com/input-output-hk/cardano-crypto
16+
commit: 4590efa638397e952a51a8994b5543e4ea3c1ecd
17+
18+
- QuickCheck-2.12.6.1
19+
- quickcheck-instances-0.3.19
20+
- hspec-2.7.0
21+
- hspec-core-2.7.0
22+
- hspec-discover-2.7.0
23+
- text-1.2.4.0
24+
- base58-bytestring-0.1.0
25+
# Waiting on Stackage release
26+
- hedgehog-1.0.2
27+
- micro-recursion-schemes-5.0.2.2
28+
- streaming-binary-0.3.0.1
29+
- cborg-0.2.2.1
30+
- canonical-json-0.6.0.0
1231
- brick-0.47
1332
- binary-0.8.7.0
1433
- bimap-0.4.0
@@ -21,12 +40,12 @@ extra-deps:
2140
- io-streams-1.5.1.0
2241
- io-streams-haproxy-1.0.1.0
2342
- moo-1.2
24-
- network-3.1.0.0
25-
- snap-core-1.0.4.0
43+
- network-3.1.1.1
44+
- snap-core-1.0.4.1
2645
- snap-server-1.1.1.1
2746
- statistics-linreg-0.3
2847
- time-units-1.0.0
29-
- tasty-hedgehog-1.0.0.1
48+
- tasty-hedgehog-1.0.0.2
3049
- transformers-except-0.1.1
3150
- text-zipper-0.10.1
3251
- Unique-0.4.7.6
@@ -114,4 +133,4 @@ extra-deps:
114133
- typed-protocols-cbor
115134

116135
nix:
117-
shell-file: shell.nix
136+
shell-file: nix/stack-shell.nix

0 commit comments

Comments
 (0)