Skip to content

Commit

Permalink
Migrate to overlay style.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbgi committed Feb 6, 2020
1 parent c246276 commit 901605a
Show file tree
Hide file tree
Showing 21 changed files with 316 additions and 370 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ steps:
system: x86_64-linux

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

Expand Down
2 changes: 1 addition & 1 deletion benchmarking/chain-sync/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LOG_CONFIG="$(yj < $BASEDIR/configuration/log-config-ci.yaml)"

CUSTOM_CONFIG="{nodeConfig = builtins.fromJSON ''$LOG_CONFIG'';}"

nix build --out-link ./launch_node -f $BASEDIR/../.. scripts.$CLUSTER.node --arg customConfig "$CUSTOM_CONFIG"
nix build --out-link ./launch_node -f $BASEDIR/../.. scripts.$CLUSTER.node --arg config "{ customScriptConfig = $CUSTOM_CONFIG; }"

rm -rf "./state-node-$CLUSTER"

Expand Down
81 changes: 18 additions & 63 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,40 @@
, crossSystem ? null
, config ? {}
, sourcesOverride ? {}
, profiling ? false
, commonLib ? import ./lib.nix { inherit system crossSystem config profiling; }
, pkgs ? commonLib.pkgs
, customConfig ? {}
, interactive ? false
, gitrev ? commonLib.iohkNix.commitIdFromGitRepoOrZero ./.git
, withHoogle ? true
, pkgs ? import ./nix { inherit system crossSystem config sourcesOverride; }
, gitrev ? pkgs.iohkNix.commitIdFromGitRepoOrZero ./.git
}:

with pkgs; with commonLib;
let
lib = commonLib.pkgs.lib;
inherit (commonLib) environments haskellPackages niv;

# we are only intersted in listing the project packages
haskellPackages = selectProjectPackages cardanoNodePackages;

cardano-node = haskellPackages.cardano-node.components.exes.cardano-node;

scripts = commonLib.pkgs.callPackage ./nix/scripts.nix {
inherit commonLib customConfig;
};
scripts = callPackage ./nix/scripts.nix {};
# NixOS tests run a proxy and validate it listens
nixosTests = import ./nix/nixos/tests {
inherit (commonLib) pkgs;
inherit commonLib interactive;
inherit pkgs;
};

# we are only intersted in listing the project packages
projectHaskellPackages = commonLib.selectProjectPackages haskellPackages;

self = with commonLib; {
inherit scripts nixosTests environments cardano-node;
self = {
inherit scripts nixosTests environments cardano-node haskellPackages;

haskellPackages = projectHaskellPackages;
inherit (iohkNix) check-hydra;

# `tests` are the test suites which have been built.
tests = collectComponents' "tests" projectHaskellPackages;
tests = collectComponents' "tests" haskellPackages;
# `benchmarks` (only built, not run).
benchmarks = collectComponents' "benchmarks" projectHaskellPackages;
benchmarks = collectComponents' "benchmarks" haskellPackages;
# `checks` collect results of executing the benchmarks and tests:
checks = {
benchmarks = collectChecks self.benchmarks;
tests = collectChecks self.tests;
tests = collectChecks haskellPackages;
} // { recurseForDerivations = true; };

shell = haskellPackages.shellFor {

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

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

# You might want some extra tools in the shell (optional).
buildInputs = with pkgs; [
cabal-install
ghcid
hlint
pkgs.haskellPackages.weeder
nix
niv
pkgconfig
sqlite-interactive
tmux
git
];

# Prevents cabal from choosing alternate plans, so that
# *all* dependencies are provided by Nix.
exactDeps = true;
};

shell = import ./shell.nix {
inherit pkgs;
withHoogle = true;
};

};
in self
42 changes: 0 additions & 42 deletions lib.nix

This file was deleted.

29 changes: 29 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? {}
, sourcesOverride ? {}
}:
let
# use default stable nixpkgs from iohk-nix instead of our own:
sources = removeAttrs (import ./sources.nix) [ "nixpkgs" ]
// sourcesOverride;

# for inclusion in pkgs:
nixpkgsOverlays = [
(pkgs: _: with pkgs; {

# mix of pkgs.lib with iohk-nix utils and our own:
commonLib = lib // iohkNix // iohkNix.cardanoLib //
import ./util.nix { inherit haskell-nix; };

svcLib = import ./svclib.nix { inherit pkgs; };
})
# Our haskell-nix-ified cabal project:
(import ./pkgs.nix)
];

# IOHK pkgs that include haskell-nix overlays, using our sources as override:
in (import sources.iohk-nix {
inherit system crossSystem config nixpkgsOverlays;
sourcesOverride = sources;
}).pkgs
2 changes: 1 addition & 1 deletion nix/nixos/cardano-cluster-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ in let
### Packages and Nix libs
cardano-node = ncfg.package;
cardano-sl-pkgs = import ccfg.cardano-sl-src { gitrev = ccfg.cardano-sl-src.rev; };
svcLib = (import ../svclib.nix { inherit pkgs; });
svcLib = pkgs.svcLib;

in let
### Node enumeration
Expand Down
6 changes: 3 additions & 3 deletions nix/nixos/cardano-node-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

with lib; with builtins;
let
commonLib = import ../../lib.nix {};
localPkgs = import ../. {};
cfg = config.services.cardano-node;
inherit (commonLib) svcLib;
inherit (localPkgs) svcLib commonLib cardanoNodePackages;
envConfig = cfg.environments.${cfg.environment}; systemdServiceName = "cardano-node${optionalString cfg.instanced "@"}";
mkScript = cfg:
let exec = "cardano-node run";
Expand Down Expand Up @@ -59,7 +59,7 @@ in {

package = mkOption {
type = types.package;
default = commonLib.haskellPackages.cardano-node.components.exes.cardano-node;
default = cardanoNodePackages.cardano-node.components.exes.cardano-node;
defaultText = "cardano-node";
description = ''
The cardano-node package that should be used
Expand Down
4 changes: 2 additions & 2 deletions nix/nixos/chairman-as-a-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
, pkgs
, ... }:

with import ../../lib.nix {}; with lib; with builtins;
with pkgs; with lib; with builtins;
let
cfg = config.services.chairman;
ncfg = config.services.cardano-node;
chairman = haskellPackages.cardano-node.components.exes.chairman;
svcLib = (import ../svclib.nix { inherit pkgs; });
svcLib = pkgs.svcLib;
envConfig = environments.${cfg.environment};
mkChairmanConfig = nodeConfig: chairmanConfig: {
inherit (nodeConfig) package genesisFile genesisHash stateDir pbftThreshold consensusProtocol;
Expand Down
5 changes: 3 additions & 2 deletions nix/nixos/tests/cardano-node-edge.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ pkgs, commonLib, ... }:

{ pkgs, ... }:
with pkgs;
{
name = "cardano-node-edge-test";
nodes = {
machine = { config, pkgs, ... }: {
nixpkgs.overlays = pkgsOverlays;
imports = [
../.
];
Expand Down
12 changes: 6 additions & 6 deletions nix/nixos/tests/chairmans-cluster.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{ pkgs
, commonLib
, interactive ? false
, config
, interactive ? config.interactive or false
, ... }:

with pkgs.lib;
with pkgs; with pkgs.commonLib;
let
svcLib = import ../../svclib.nix { pkgs = commonLib.pkgs; };
byron-proxy-src = (import ../../sources.nix).cardano-byron-proxy;
cardano-sl-src = (import ../../sources.nix).cardano-sl;
byron-proxy-src = sources.cardano-byron-proxy;
cardano-sl-src = sources.cardano-sl;
# byron-proxy-src = ../../../../cardano-byron-proxy;
# cardano-sl-src = ../../../../cardano-sl;
cardano-sl-config = pkgs.runCommand "cardano-sl-config" {} ''
Expand Down Expand Up @@ -35,6 +34,7 @@ in {
name = "chairmans-cluster-test";
nodes = {
machine = { lib, config, pkgs, ... }: {
nixpkgs.overlays = pkgsOverlays;
imports = [
(byron-proxy-src + "/nix/nixos")
../cardano-node-service.nix
Expand Down
14 changes: 5 additions & 9 deletions nix/nixos/tests/default.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
{ pkgs ? (import <nixpkgs> {})
, commonLib
{ pkgs
, supportedSystems ? [ "x86_64-linux" ]
, interactive ? false
}:

with pkgs;
with pkgs.lib;
with pkgs.commonLib;

let
forAllSystems = genAttrs supportedSystems;
importTest = fn: args: system: let
imported = import fn;
test = import (pkgs.path + "/nixos/tests/make-test.nix") imported;
in test ({
inherit system;
inherit pkgs system config;
} // args);
callTest = fn: args: forAllSystems (system: hydraJob (importTest fn args system));
in rec {
# only tests that port is open since the test can't access network to actually sync
# cardanoNodeEdge = callTest ./cardano-node-edge.nix { inherit commonLib; };
# cardanoNodeEdge = callTest ./cardano-node-edge.nix {};

# Subsumes what cardanoNodeEdge does
chairmansCluster = callTest ./chairmans-cluster.nix {
inherit commonLib interactive;
};
chairmansCluster = callTest ./chairmans-cluster.nix {};
}
Loading

0 comments on commit 901605a

Please sign in to comment.