Skip to content

Commit

Permalink
wb | indentation and cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaste committed Sep 18, 2024
1 parent 421ad95 commit 7ebeb26
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 41 deletions.
2 changes: 1 addition & 1 deletion nix/pkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let
inherit (prev.pkgs) lib;
inherit (prev) customConfig;

# A generic, fully parameteric version of the workbench development environment.
# A generic, fully parametric version of the workbench development environment.
workbench = import ./workbench
{inherit pkgs lib; inherit (final) cardanoNodePackages cardanoNodeProject;};

Expand Down
93 changes: 53 additions & 40 deletions nix/workbench/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,51 @@
with lib;

let
# recover CHaP location from cardano's project
chap = cardanoNodeProject.args.inputMap."https://chap.intersectmbo.org/";
# build plan as computed by nix
nixPlanJson = cardanoNodeProject.plan-nix.json;

workbench' = tools:
pkgs.stdenv.mkDerivation {
pname = "workbench";
# Workbench derivation and function to create derivations from `wb` commands.
##############################################################################

version = "0.1";

src = ./.;

buildInputs = with pkgs; [ makeWrapper ];

buildPhase = ''
patchShebangs .
'';

postFixup = ''
wrapProgram "$out/bin/wb" \
--argv0 wb \
--prefix PATH ":" ${makeBinPath tools} \
--set WB_CHAP_PATH ${chap} \
--set WB_NIX_PLAN ${nixPlanJson}
'';

installPhase = ''
mkdir -p $out/bin
cp -a wb ede profile $out/bin
for dir in . analyse backend genesis topology
do cp -a $dir/* $out/bin/$dir
done
'';

dontStrip = true;
};
workbench' =
let
# recover CHaP location from cardano's project
chap = cardanoNodeProject.args.inputMap."https://chap.intersectmbo.org/";
# build plan as computed by nix
nixPlanJson = cardanoNodeProject.plan-nix.json;
in tools:
pkgs.stdenv.mkDerivation {
pname = "workbench";

version = "0.1";

src = ./.;

buildInputs = with pkgs; [ makeWrapper ];

buildPhase = ''
patchShebangs .
'';

postFixup = ''
wrapProgram "$out/bin/wb" \
--argv0 wb \
--prefix PATH ":" ${makeBinPath tools} \
--set WB_CHAP_PATH ${chap} \
--set WB_NIX_PLAN ${nixPlanJson}
'';

installPhase = ''
mkdir -p $out/bin
cp -a wb ede profile $out/bin
for dir in . analyse backend genesis topology
do cp -a $dir/* $out/bin/$dir
done
'';

dontStrip = true;
}
;

# Workbench with its dependencies to call from Nix.
workbench = with cardanoNodePackages; with pkgs; workbench' (
[ git graphviz
jq
Expand All @@ -58,24 +65,30 @@ let
);

runWorkbench =
name: command:
name: command: # Name of the derivation and `wb` command to run.
pkgs.runCommand name {} ''
${workbench}/bin/wb ${command} > $out
'';

# Helper functions.
##############################################################################

runJq =
name: args: query:
pkgs.runCommand name {} ''
args=(${args})
${pkgs.jq}/bin/jq '${query}' "''${args[@]}" > $out
'';

profile-names-json =
runWorkbench "profile-names.json" "profiles list";
# Auxiliary functions of `wb` commands.
##############################################################################

profile-names = __fromJSON (__readFile profile-names-json);

profile-names =
__fromJSON (__readFile profile-names-json);
profile-names-json = runWorkbench "profile-names.json" "profiles list";

# Output
################################################################################
in pkgs.lib.fix (self: {
inherit cardanoNodePackages;
inherit workbench' workbench runWorkbench;
Expand Down

0 comments on commit 7ebeb26

Please sign in to comment.