Fractals are third party Fractalide libraries.
Fractals
are importable 3rd party sets of nodes, subgraphs and edges, this folder hierarchy is the single source of truth regarding where to find each community fractal.
Fractals
allow the community to develop their own projects in their own git repository, and once ready, may plug into dev/fractalide/fractals
folder hierarchy which represents the spine of Fractalide. Once inserted your fractal
is available for use by everyone.
Anyone making high quality, documented nodes, subgraphs and edges may plug into this folder hierarchy. We use the C4 so your fractals
will be merged in quickly.
Each fractal
needs to have its own hierarchical folder. For example, HTTP would be placed in the fractalide/fractals/net/http
folder.
Say you wish to create a http
project, these are the exact steps involved:
-
Ensure you use this directory structure convention:
dev
├── fractalide
│ └── fractals
│ └── net
│ └── http
│ └── default.nix
└── fractals
├── fractal_net_http
└── ... more community fractals cloned
$ cd <your/development/directory>
$ git clone \https://gitlab.com/fractalide/fractalide.git
$ NIX_PATH="nixpkgs=https://github.com/NixOS/nixpkgs/archive/125ffff089b6bd360c82cf986d8cc9b17fc2e8ac.tar.gz:fractalide=/path/to/dev/fractalide" && export NIX_PATH` (1)
$ mkdir dev/fractals && cd dev/fractals
$ git clone git://github.com/fractalide/fractal_workbench.git fractal_net_http (2)
$ git remote set-url origin git://new.url.you.control.here
$ mkdir -p dev/fractalide/fractals/net/http/ (3)
-
Take note when setting the
NIX_PATH
environment variable, it must include the path to your newly clonedfractalide
repo i.e.:NIX_PATH=…:fractalide=/path/to/dev/fractalide
.
Should you start a new shell, type<ctrl>-r
then type125ff
this will search your command history for the above command, or just persist the command in your~/.bashrc
file. -
The
fractal_workbench
repo provides a minimum correct structure for yourfractal
. Keep the repo naming conventionfractal_*
for your repo as it’ll be easy for the community to see this is afractalide
related project. -
Create your needed directory hierarchy
dev/fractalide/fractals/net/http/default.nix
.
Insert the below code into a file called default.nix
which sits in the above folder.
{ pkgs
, support
, edges
, nodes
, fetchFromGitHub
, ...}:
let
fractal = fetchFromGitHub {
owner = "fractalide";
repo = "fractal_net_http";
rev = "66ad3bf74b04627edc71227b3e5b944561854367";
sha256 = "1vs1d3d9lbxnyilx8g45pb01z5cl2z3gy4035h24p28p9v94jx1b";
};
/*fractal = ../../../../fractals/fractal_net_http;*/
in
import fractal {inherit pkgs support edges nodes; fractalide = null;}
Note
|
|
The last step is to expose the exact nodes / edges to dev/fractalide/nodes/default.nix
and dev/fractalide/edges/default.nix
.
This is done in this manner:
-
Open
dev/fractalide/nodes/default.nix
and seek out thenet_http_nodes
attribute. This is what it looks like:net_http_nodes = fractals.net_http.nodes;
In this case there is no specific top level node you’d wish to expose so the convention_nodes
is used to indicate this. Whereas if you have a specific node you’d wish to expose then you’d name it as such:net_http = fractals.net_http.nodes.http
. Why the.http
? well that’s what the node is named in the namespace here. Please notice the lack of the*_nodes
when exporting a single node. -
Regarding importing edges, typically you don’t need to import edges, but there are times when you need a special edge which must operate on the public side of the
fractal
and thus usable across a number offractals
, say thenet_http_edges.request
You’d use a similar mechanism as above when exposing your edges.
Incremental Builds speed up the development process, so that one doesn’t have to compile the entire crate from scratch each time you make a change to the source code.
Fractalide expands the nix-build system for incremental builds. The Incremental Builds only work when debug is enabled. They also need the path to a cache folder.
The cache folder can be created from an old result by the buildCache.sh
script. Per default the cache folder is saved in the /tmp
folder of your system. Incremental Builds permit you to compile a crate without having to recompile the crate dependency tree.
Here is an example how you can build with the Incremental Build System:
$ cd dev/fractalide
$ nix-build --argstr debug true --argstr cache $(./support/buildCache.sh) --argstr subgraph workbench
If you’re using NixOS, please ensure you have not set nix.useSandbox = true;
, otherwise Incremental Compilation will fail.
-
Please read this.
$ cd dev/fractalide
$ nix-build --argstr rs workbench
$ ./result
-
advantages
-
Incremental recompilation needed for development
-
-
disadvantages
-
wetware needed to plug into
dev/fractalide/fractals
to get incremental recompilation -
long build command
-