From 7ebeb268a6d42188801a8005b70f9f333ac0193e Mon Sep 17 00:00:00 2001 From: Federico Mastellone Date: Wed, 18 Sep 2024 13:21:01 +0000 Subject: [PATCH] wb | indentation and cleaning --- nix/pkgs.nix | 2 +- nix/workbench/default.nix | 93 ++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 41 deletions(-) diff --git a/nix/pkgs.nix b/nix/pkgs.nix index 1228fda671f..4f54659d04e 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -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;}; diff --git a/nix/workbench/default.nix b/nix/workbench/default.nix index f657a47333b..386b2695c5d 100644 --- a/nix/workbench/default.nix +++ b/nix/workbench/default.nix @@ -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 @@ -58,11 +65,14 @@ 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 {} '' @@ -70,12 +80,15 @@ let ${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;