Skip to content

Commit

Permalink
workbench: provide as an attribute from default.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Jan 17, 2022
1 parent e503669 commit 40753a2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -48,7 +48,7 @@ cluster-profiles: ## List available workbench profiles (for PROFILE=)
@./nix/workbench/wb profile list

cluster-shell: ## Enter Nix shell and start the workbench cluster
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr clusterProfile ${PROFILE} --arg 'autoStartCluster' true
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} --arg 'autoStartCluster' true

shell-dev: ARGS += --arg 'workbenchDevMode' true ## Enter Nix shell, dev mode (workbench run from checkout)
cluster-shell: ARGS += --arg 'autoStartCluster' true --arg 'workbenchDevMode' true ## Enter Nix shell, and start workbench cluster
Expand All @@ -58,7 +58,7 @@ cluster-shell-dev-trace: ARGS += --arg 'autoStartCluster' true --arg 'workbenchD
shell-dev cluster-shell-dev cluster-shell-trace cluster-shell-dev-trace: shell

shell: ## Enter Nix shell, CI mode (workbench run from Nix store)
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr clusterProfile ${PROFILE} ${ARGS}
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} ${ARGS}

cli node:
cabal --ghc-options="+RTS -qn8 -A32M -RTS" build cardano-$@
Expand Down
24 changes: 22 additions & 2 deletions default.nix
@@ -1,22 +1,39 @@
let defaultCustomConfig = import ./nix/custom-config.nix defaultCustomConfig;
# This file is used by nix-shell.
# It just takes the shell attribute from default.nix.
in
{ system ? builtins.currentSystem
, crossSystem ? null
# allows to cutomize haskellNix (ghc and profiling, see ./nix/haskell.nix)
, config ? {}
# override scripts with custom configuration
, customConfig ? {}
, withHoogle ? defaultCustomConfig.withHoogle
, profileName ? defaultCustomConfig.localCluster.profileName
, autoStartCluster ? defaultCustomConfig.localCluster.autoStartCluster
, workbenchDevMode ? defaultCustomConfig.localCluster.workbenchDevMode
, customConfig ? {
inherit withHoogle;
localCluster = {
inherit autoStartCluster profileName workbenchDevMode;
};
}
# allows to override dependencies of the project without modifications,
# eg. to test build against local checkout of nixpkgs and iohk-nix:
# nix build -f default.nix cardano-node --arg sourcesOverride '{
# iohk-nix = ../iohk-nix;
# }'
, sourcesOverride ? {}
# pinned version of nixpkgs augmented with overlays (iohk-nix and our packages).
, pkgs ? import ./nix/default.nix { inherit system crossSystem config customConfig sourcesOverride gitrev; }
, pkgs ? import ./nix {
inherit system crossSystem config customConfig sourcesOverride gitrev;
}
# Git sha1 hash, to be passed when not building from a git work tree.
, gitrev ? null
}:
with pkgs; with commonLib;
let
inherit (pkgs) customConfig;
inherit (customConfig) localCluster;

haskellPackages = recRecurseIntoAttrs
# the Haskell.nix package set, reduced to local packages.
Expand All @@ -36,6 +53,9 @@ let
tx-generator tx-generator-profiled
scripts environments dockerImage submitApiDockerImage bech32;

clusterCabal = mkSupervisordCluster { inherit profileName; useCabalRun = true; };
clusterNix = mkSupervisordCluster { inherit profileName; useCabalRun = false; };

devopsShell = shell.devops;

devShell = shell.dev;
Expand Down
5 changes: 2 additions & 3 deletions nix/supervisord-cluster/tests/default.nix
@@ -1,10 +1,9 @@
{ pkgs
, mkCluster
}: let
inherit (pkgs) mkCluster cardano-cli cardanolib-py cardano-node;
inherit (pkgs) mkSupervisordCluster cardano-cli cardanolib-py cardano-node;
stateDir = "./state-cluster-test";
# We want a really short duration for tests
cluster' = mkCluster {
cluster' = mkSupervisordCluster {
genesisParams = {
slotLength = 0.1;
decentralisationParam = 0.8;
Expand Down
13 changes: 13 additions & 0 deletions nix/svclib.nix
Expand Up @@ -231,11 +231,24 @@ let
processScriptDeclaration =
name: decl:
extractServiceScript (decl // { svcName = name; });

# This provides a development environment that can be used with nix-shell or
# lorri. See https://input-output-hk.github.io/haskell.nix/user-guide/development/
# NOTE: due to some cabal limitation,
# you have to remove all `source-repository-package` entries from cabal.project
# after entering nix-shell for cabal to use nix provided dependencies for them.
mkSupervisordCluster =
{ useCabalRun, profileName }:
pkgs.callPackage ./supervisord-cluster
{ inherit profileName useCabalRun;
workbench = pkgs.callPackage ./workbench { inherit useCabalRun; };
};
in
{
inherit
defServiceModule
mkScriptOfService
mkServiceScript
mkSupervisordCluster
;
}
33 changes: 13 additions & 20 deletions shell.nix
Expand Up @@ -5,15 +5,14 @@ in
{ config ? {}
, sourcesOverride ? {}
, withHoogle ? defaultCustomConfig.withHoogle
, clusterProfile ? defaultCustomConfig.localCluster.profileName
, profileName ? defaultCustomConfig.localCluster.profileName
, autoStartCluster ? defaultCustomConfig.localCluster.autoStartCluster
, autoStartClusterArgs ? ""
, workbenchDevMode ? defaultCustomConfig.localCluster.workbenchDevMode
, customConfig ? {
inherit withHoogle;
localCluster = {
inherit autoStartCluster workbenchDevMode;
profileName = clusterProfile;
inherit autoStartCluster profileName workbenchDevMode;
};
}
, pkgs ? import ./nix {
Expand All @@ -23,8 +22,8 @@ in
with pkgs;
let
inherit (pkgs) customConfig;
inherit (customConfig) withHoogle localCluster withR;
inherit (localCluster) autoStartCluster workbenchDevMode;
inherit (customConfig) withHoogle localCluster;
inherit (localCluster) autoStartCluster profileName workbenchDevMode;
commandHelp =
''
echo "
Expand All @@ -50,20 +49,11 @@ let

haveGlibcLocales = pkgs.glibcLocales != null && stdenv.hostPlatform.libc == "glibc";

# This provides a development environment that can be used with nix-shell or
# lorri. See https://input-output-hk.github.io/haskell.nix/user-guide/development/
# NOTE: due to some cabal limitation,
# you have to remove all `source-repository-package` entries from cabal.project
# after entering nix-shell for cabal to use nix provided dependencies for them.
mkCluster =
{ useCabalRun, profileName ? localCluster.profileName }:
callPackage ./nix/supervisord-cluster
{ inherit profileName useCabalRun;
workbench = pkgs.callPackage ./nix/workbench { inherit useCabalRun; };
};

shell =
let cluster = mkCluster { useCabalRun = true; };
let cluster = pkgs.commonLib.mkSupervisordCluster
{ inherit profileName;
useCabalRun = true;
};
in cardanoNodeProject.shellFor {
name = "cluster-shell";

Expand Down Expand Up @@ -117,7 +107,7 @@ let
exactDeps = true;

shellHook = ''
echo 'nix-shell options & flags: withHoogle=${toString withHoogle} clusterProfile=${clusterProfile} autoStartCluster=${toString autoStartCluster} workbenchDevMode=${toString workbenchDevMode}'
echo 'nix-shell options & flags: withHoogle=${toString withHoogle} profileName=${profileName} autoStartCluster=${toString autoStartCluster} workbenchDevMode=${toString workbenchDevMode}'
${cluster.workbench.shellHook}
Expand Down Expand Up @@ -145,7 +135,10 @@ let
};

devops =
let cluster = mkCluster { useCabalRun = false; profileName = "devops-alzo"; };
let cluster = pkgs.commonLib.mkSupervisordCluster
{ profileName = "devops-alzo";
useCabalRun = false;
};
in cardanoNodeProject.shellFor {
name = "devops-shell";

Expand Down

0 comments on commit 40753a2

Please sign in to comment.