Skip to content

Latest commit

 

History

History

services

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Services

What?

Services are reusable and consist of agents, subgraphs and edges. They may be connected to other services on the same system or on remote machines in a high performance cluster quite easily.

Why?

Services allow programmers to collaborate and distill common configurable patterns that solve general problems. Essentially a service in this context is no different from a top level subgraph, albeit the interface has been nix’ified. The `nix interface is required because this is where nixos takes over and declaratively handles congruent configuration management. It does things like set up dependencies such as databases and other services that might need to be run for the subgraph to operate properly. This layer of software has been well tested by the nix community and ties in with every other service created by the nixos community.

This abstraction allows you to pull in legacy services, plug a Cap’n Proto functionality and start talking to Fractalide services.

Who?

Anyone who has completed a high quality, documented hierarchy of components, subnets and contracts, and where the hierarchy makes sense to expose as a service. We use the [C4](../CONTRIBUTING.md) so your services will be merged in quickly.

Where?

Service implementations by convention exist in a fractal’s root folder. It doesn’t make sense to expose every fractal as a service. Though if the fractal is dependent on other services such as databases, then it might make sense. Nevertheless, the fractals which have a service.nix may have their components and contracts imported into higher level subnets via the [fractals] importing mechanism. This higher level subnet may then be exposed as a service.

How?

  • First create a fractal

  • Update the service.nix file to reflect what options you want exposed on the service interface.

  • Ensure the subnet you want is correctly configured.

  • Add a line the fractalide/services/default.nix where you make your service visible to the rest of the fractalide community.

Two ways to run a service

From your Fractal

This approach is when you have a service you don’t consider generic and is not worth sharing with the community.

in your configuration.nix put these lines:

configuration.nix
{ config, pkgs, ... }:
let
  fractalide = import fetchFromGitHub {
    owner = "fractalide";
    repo = "fractalide";
    rev = "b9590b6{ git revision you want }f130ed79432c722";
    sha256 = "0jz58mmax5{ correct sha256 generated by nix }yycmzr26xwfqa";
  } {};
in
{
  require = fractalide.services    [ "/path/to/private/dev/fractals/fractal_your_fractal/service.nix" ];
  services.workbench = {
    enable = true;
    bindAddress = "192.168.0.14";
    port = 8000;
  };
  services.your_service = {
    enable = true;
    bindAddress = "192.168.0.15";
    port = 8001;
  };
  # ... other options you want
}

From Fractalide

in your configuration.nix put these lines:

configuration.nix
let
  fractalide = import fetchFromGitHub {
    owner = "fractalide";
    repo = "fractalide";
    rev = "b9590b6{ git revision you want }f130ed79432c722";
    sha256 = "0jz58mmax5{ correct sha256 generated by nix }yycmzr26xwfqa";
  } {};
in
{
require = fractalide.services;
services.workbench = {
        enable = true;
        bindAddress = "127.0.0.1";
        port = 8000;
};
# ... other options you want
  • At this point, you may either choose to build nixops infrastructure scripts and deploy or simply run $ nixos-rebuild {test, boot , switch} to set up the services on your own system.

  • Do help out building generic services for programmers to speed up their work!