Manyfold

ActivityPub-powered tool for storing and sharing 3d models

Declared in: projects/Manyfold/default.nix

Try the service in a VM

  1. Install Nix
    Bash
    $ apt install --yes curl git jq nix
    Bash
    $ apt install --yes curl git jq nix
    Bash
    $ pacman --sync --refresh --noconfirm curl git jq nix
  2. Download a configuration file
    # default.nix
    {
      ngipkgs ? import (fetchTarball "https://github.com/ngi-nix/ngipkgs/tarball/main") { },
    }:
    ngipkgs.demo-vm (
      { config, pkgs, ... }:
    
      {
        services.manyfold = {
          enable = true;
          settings = {
            # Do *NOT* do this in production!
            SECRET_KEY_BASE = "0123456789abcdef0123456789abcdef";
            DATABASE_ADAPTER = "postgresql";
            DATABASE_HOST = "127.0.0.1";
            DATABASE_PORT = toString config.services.postgresql.settings.port;
            # Do *NOT* do this in production!
            DATABASE_USER = "manyfold";
            DATABASE_PASSWORD = "manyfold";
            DATABASE_NAME = "manyfold";
          };
        };
    
        services.redis.servers.manyfold.port = 6379;
    
        systemd.services.manyfold.after = [ "postgresql.service" ];
        services.postgresql = {
          enable = true;
          ensureDatabases = [ "manyfold" ];
          ensureUsers = [
            {
              name = "manyfold";
              ensureDBOwnership = true;
            }
          ];
          # Do *NOT* do this in production!
          initialScript = pkgs.writeText "init-sql-script" ''
            CREATE ROLE manyfold LOGIN PASSWORD 'manyfold';
          '';
        };
      }
    )
    
  3. Enable binary substituters
    Bash
    $ export NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/
    trusted-public-keys = cache.nixos.org-1:6nchdd59x431o0gwypbmraurkbj16zpmqfgspcdshjy= ngi.cachix.org-1:n+cal72roc3qqulxihpv+tw5t42whxmmhpragkrsrow='
  4. Build and run a virtual machine
    Bash
    $ nix-build ./default.nix && ./result
    Bash
    $ nix-build ./default.nix && ./result
    Bash
    $ rev=$(nix-instantiate --eval --attr sources.nixpkgs.rev https://github.com/ngi-nix/ngipkgs/archive/master.tar.gz | jq --raw-output)
    $ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/$rev.tar.gz --packages nix --run "nix-build ./default.nix && ./result"
    Bash
    $ nix-build ./default.nix && ./result
  5. Usage Instructions
    1. Visit http://127.0.0.1:3214 in your browser

    2. Follow on screen instructions to create an account and a library.

    3. Try to upload 3D model assets.

Examples

Enable Manyfold with PostgreSQL
{ config, pkgs, ... }:

{
  services.manyfold = {
    enable = true;
    settings = {
      # Do *NOT* do this in production!
      SECRET_KEY_BASE = "0123456789abcdef0123456789abcdef";
      DATABASE_ADAPTER = "postgresql";
      DATABASE_HOST = "127.0.0.1";
      DATABASE_PORT = toString config.services.postgresql.settings.port;
      # Do *NOT* do this in production!
      DATABASE_USER = "manyfold";
      DATABASE_PASSWORD = "manyfold";
      DATABASE_NAME = "manyfold";
    };
  };

  services.redis.servers.manyfold.port = 6379;

  systemd.services.manyfold.after = [ "postgresql.service" ];
  services.postgresql = {
    enable = true;
    ensureDatabases = [ "manyfold" ];
    ensureUsers = [
      {
        name = "manyfold";
        ensureDBOwnership = true;
      }
    ];
    # Do *NOT* do this in production!
    initialScript = pkgs.writeText "init-sql-script" ''
      CREATE ROLE manyfold LOGIN PASSWORD 'manyfold';
    '';
  };
}

Declared in: projects/Manyfold/services/manyfold/examples/postgresql.nix

Enable Manyfold with SQLite
{ ... }:

{
  services.manyfold = {
    enable = true;
    settings = {
      # Do *NOT* do this in production!
      SECRET_KEY_BASE = "0123456789abcdef0123456789abcdef";
      DATABASE_ADAPTER = "sqlite3";
      DATABASE_NAME = "/var/lib/manyfold/manyfold.sqlite3";
    };
  };

  services.redis.servers.manyfold.port = 6379;
}

Declared in: projects/Manyfold/services/manyfold/examples/sqlite.nix

This project is funded by NLnet through these subgrants:

Commons
Manyfold-Discovery
Entrust
Personal-3D-archive

Related links: