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

[DEVOPS-1067] [nix] Split overlays into their own files #3690

Merged
merged 3 commits into from
Oct 3, 2018
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
117 changes: 15 additions & 102 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,114 +26,26 @@ in
}:

with pkgs.lib;
with pkgs.haskell.lib;

let
justStaticExecutablesGitRev = import ./scripts/set-git-rev {
inherit pkgs gitrev;
inherit (cardanoPkgs) ghc;
};
addRealTimeTestLogs = drv: overrideCabal drv (attrs: {
testTarget = "--show-details=streaming";
# the GHC we are using
# at some point use: pkgs.haskell.compiler.ghc843;
ghc = overrideDerivation pkgs.haskell.compiler.ghc822 (drv: {
patches = drv.patches ++ [ ./ghc-8.0.2-darwin-rec-link.patch ];
});

requiredOverlay = self: super: {
inherit pkgs;
srcroot = ./.;
cardano-sl-core = overrideCabal super.cardano-sl-core (drv: {
configureFlags = (drv.configureFlags or []) ++ [
"-f-asserts"
];
});
cardano-sl = overrideCabal super.cardano-sl (drv: {
# production full nodes shouldn't use wallet as it means different constants
configureFlags = (drv.configureFlags or []) ++ [
"-f-asserts"
];
passthru = {
inherit enableProfiling;
};
});
cardano-sl-wallet-static = justStaticExecutablesGitRev self.cardano-sl-wallet;
cardano-sl-client = addRealTimeTestLogs super.cardano-sl-client;
cardano-sl-generator = addRealTimeTestLogs super.cardano-sl-generator;
cardano-sl-networking = addRealTimeTestLogs super.cardano-sl-networking;
cardano-sl-auxx-static = justStaticExecutablesGitRev self.cardano-sl-auxx;
cardano-sl-wallet-new-static = justStaticExecutablesGitRev self.cardano-sl-wallet-new;
cardano-sl-node-static = justStaticExecutablesGitRev self.cardano-sl-node;
cardano-sl-explorer-static = justStaticExecutablesGitRev self.cardano-sl-explorer;
cardano-report-server-static = justStaticExecutablesGitRev self.cardano-report-server;
cardano-sl-faucet-static = justStaticExecutablesGitRev self.cardano-sl-faucet;
cardano-sl-tools-static = justStaticExecutablesGitRev self.cardano-sl-tools;
# Undo configuration-nix.nix change to hardcode security binary on darwin
# This is needed for macOS binary not to fail during update system (using http-client-tls)
# Instead, now the binary is just looked up in $PATH as it should be installed on any macOS
x509-system = overrideDerivation super.x509-system (drv: {
postPatch = ":";
});

# TODO: get rid of pthreads option once cryptonite 0.25 is released
# DEVOPS-393: https://github.com/haskell-crypto/cryptonite/issues/193
cryptonite = appendPatch (appendConfigureFlag super.cryptonite "--ghc-option=-optl-pthread") ./pkgs/cryptonite-segfault-blake.patch;

# Due to https://github.com/input-output-hk/stack2nix/issues/56
hfsevents = self.callPackage ./pkgs/hfsevents.nix { inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa CoreServices; };
mkDerivation = args: super.mkDerivation (args // {
enableLibraryProfiling = enableProfiling;
enableExecutableProfiling = enableProfiling;
# Static linking for everything to work around
# https://ghc.haskell.org/trac/ghc/ticket/14444
# This will be the default in nixpkgs since
# https://github.com/NixOS/nixpkgs/issues/29011
enableSharedExecutables = false;
} // optionalAttrs (args ? src) {
src = localLib.cleanSourceTree args.src;
});
};
benchmarkOverlay = self: super: {
mkDerivation = args: super.mkDerivation (args // optionalAttrs (localLib.isCardanoSL args.pname) {
# Enables building but not running of benchmarks for all
# cardano-sl packages when enableBenchmarks argument is true.
doBenchmark = true;
configureFlags = (args.configureFlags or []) ++ ["--enable-benchmarks"];
} // optionalAttrs (localLib.isBenchmark args) {
# Provide a dummy installPhase for benchmark packages.
installPhase = "mkdir -p $out";
});
};

debugOverlay = self: super: {
mkDerivation = args: super.mkDerivation (args // {
# TODO: DEVOPS-355
dontStrip = true;
configureFlags = (args.configureFlags or []) ++ [ "--ghc-options=-g --disable-executable-stripping --disable-library-stripping" "--profiling-detail=toplevel-functions"];
});
};

# Disabling optimization for cardano-sl packages will
# return a build ~20% faster (measured in DEVOPS-1032).
fasterBuildOverlay = self: super: {
mkDerivation = args: super.mkDerivation (args // optionalAttrs (localLib.isCardanoSL args.pname) {
configureFlags = (args.configureFlags or []) ++ [ "--ghc-options=-O0" ];
});
};

dontCheckOverlay = self: super: {
mkDerivation = args: super.mkDerivation (args // {
doCheck = false;
});
};

metricOverlay = self: super: {
mkDerivation = args: super.mkDerivation (args // {
enablePhaseMetrics = true;
});
};
# Overlay logic for *haskell* packages.
requiredOverlay = import ./nix/overlays/required.nix { inherit pkgs localLib enableProfiling gitrev;
inherit (cardanoPkgs) ghc; };
benchmarkOverlay = import ./nix/overlays/benchmark.nix { inherit pkgs localLib; };
debugOverlay = import ./nix/overlays/debug.nix { inherit pkgs; };
fasterBuildOverlay = import ./nix/overlays/faster-build.nix { inherit pkgs localLib; };
dontCheckOverlay = import ./nix/overlays/dont-check.nix { inherit pkgs; };
metricOverlay = import ./nix/overlays/metric.nix { inherit pkgs; };

# This will yield a set of haskell packages, based on the given compiler.
cardanoPkgsBase = ((import ./pkgs { inherit pkgs; }).override {
ghc = overrideDerivation pkgs.haskell.compiler.ghc822 (drv: {
patches = drv.patches ++ [ ./ghc-8.0.2-darwin-rec-link.patch ];
});
inherit ghc;
});

activeOverlays = [ requiredOverlay ]
Expand All @@ -150,6 +62,7 @@ let
in
args: pkgs.callPackage ./scripts/launch/connect-to-cluster (args // { inherit gitrev useStackBinaries; } // walletConfig );
other = rec {
inherit pkgs;
testlist = innerClosePropagation [] [ cardanoPkgs.cardano-sl ];
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev useStackBinaries; };
validateJson = pkgs.callPackage ./tools/src/validate-json {};
Expand Down
15 changes: 15 additions & 0 deletions nix/overlays/benchmark.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ pkgs, localLib }:

with localLib;

self: super: {
mkDerivation = args: super.mkDerivation (args // optionalAttrs (isCardanoSL args.pname) {
# Enables building but not running of benchmarks for all
# cardano-sl packages when enableBenchmarks argument is true.
doBenchmark = true;
configureFlags = (args.configureFlags or []) ++ ["--enable-benchmarks"];
} // optionalAttrs (isBenchmark args) {
# Provide a dummy installPhase for benchmark packages.
installPhase = "mkdir -p $out";
});
}
9 changes: 9 additions & 0 deletions nix/overlays/debug.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ pkgs }:

self: super: {
mkDerivation = args: super.mkDerivation (args // {
# TODO: DEVOPS-355
dontStrip = true;
configureFlags = (args.configureFlags or []) ++ [ "--ghc-options=-g --disable-executable-stripping --disable-library-stripping" "--profiling-detail=toplevel-functions"];
});
}
7 changes: 7 additions & 0 deletions nix/overlays/dont-check.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ pkgs }:

self: super: {
mkDerivation = args: super.mkDerivation (args // {
doCheck = false;
});
}
12 changes: 12 additions & 0 deletions nix/overlays/faster-build.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Disabling optimization for cardano-sl packages will
# return a build ~20% faster (measured in DEVOPS-1032).

{ pkgs, localLib }:

with localLib;

self: super: {
mkDerivation = args: super.mkDerivation (args // optionalAttrs (isCardanoSL args.pname) {
configureFlags = (args.configureFlags or []) ++ [ "--ghc-options=-O0" ];
});
}
7 changes: 7 additions & 0 deletions nix/overlays/metric.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ pkgs }:

self: super: {
mkDerivation = args: super.mkDerivation (args // {
enablePhaseMetrics = true;
});
}
77 changes: 77 additions & 0 deletions nix/overlays/required.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{ pkgs, localLib, enableProfiling, gitrev, ghc }:

with pkgs.haskell.lib;
with localLib;

let
justStaticExecutablesGitRev = import ../../scripts/set-git-rev {
inherit pkgs gitrev ghc;
};
addRealTimeTestLogs = drv: overrideCabal drv (attrs: {
testTarget = "--show-details=streaming";
});
in

self: super: {

########################################################################
# Overides of Cardano SL packages

cardano-sl-core = overrideCabal super.cardano-sl-core (drv: {
configureFlags = (drv.configureFlags or []) ++ [
"-f-asserts"
];
});
cardano-sl = overrideCabal super.cardano-sl (drv: {
# production full nodes shouldn't use wallet as it means different constants
configureFlags = (drv.configureFlags or []) ++ [
"-f-asserts"
];
passthru = {
inherit enableProfiling;
};
});
cardano-sl-wallet-static = justStaticExecutablesGitRev super.cardano-sl-wallet;
cardano-sl-client = addRealTimeTestLogs super.cardano-sl-client;
cardano-sl-generator = addRealTimeTestLogs super.cardano-sl-generator;
cardano-sl-networking = addRealTimeTestLogs super.cardano-sl-networking;
cardano-sl-auxx-static = justStaticExecutablesGitRev super.cardano-sl-auxx;
cardano-sl-wallet-new-static = justStaticExecutablesGitRev super.cardano-sl-wallet-new;
cardano-sl-node-static = justStaticExecutablesGitRev self.cardano-sl-node;
cardano-sl-explorer-static = justStaticExecutablesGitRev self.cardano-sl-explorer;
cardano-report-server-static = justStaticExecutablesGitRev self.cardano-report-server;
cardano-sl-faucet-static = justStaticExecutablesGitRev self.cardano-sl-faucet;
cardano-sl-tools-static = justStaticExecutablesGitRev super.cardano-sl-tools;

########################################################################
# The base Haskell package builder

mkDerivation = args: super.mkDerivation (args // {
enableLibraryProfiling = enableProfiling;
enableExecutableProfiling = enableProfiling;
# Static linking for everything to work around
# https://ghc.haskell.org/trac/ghc/ticket/14444
# This will be the default in nixpkgs since
# https://github.com/NixOS/nixpkgs/issues/29011
enableSharedExecutables = false;
} // optionalAttrs (args ? src) {
src = localLib.cleanSourceTree args.src;
});

########################################################################
# Configuration of overrides for other dependencies

# Undo configuration-nix.nix change to hardcode security binary on darwin
# This is needed for macOS binary not to fail during update system (using http-client-tls)
# Instead, now the binary is just looked up in $PATH as it should be installed on any macOS
x509-system = overrideDerivation super.x509-system (drv: {
postPatch = ":";
});

# TODO: get rid of pthreads option once cryptonite 0.25 is released
# DEVOPS-393: https://github.com/haskell-crypto/cryptonite/issues/193
cryptonite = appendPatch (appendConfigureFlag super.cryptonite "--ghc-option=-optl-pthread") ../../pkgs/cryptonite-segfault-blake.patch;

# Due to https://github.com/input-output-hk/stack2nix/issues/56
hfsevents = self.callPackage ../../pkgs/hfsevents.nix { inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa CoreServices; };
}