···4848redis-server4949```50505151-## running knots and spindles in a VM5151+## running knots and spindles52525353An end-to-end knot setup requires setting up a machine with5454`sshd`, `AuthorizedKeysCommand`, and git user, which is5555quite cumbersome. So the nix flake provides a5656`nixosConfiguration` to do so.57575858-### Mac-specific: setting up a Nix builder5858+<details>5959+ <summary><strong>MacOS users will have to setup a Nix Builder first</strong></summary>59606060-In order to build Tangled's dev VM on macOS, you will first need to set up a6161-Linux Nix builder. The recommended way to do so is to run a6262-[`darwin.linux-builder` VM][darwin builder vm] and to register it in `nix.conf`6363-as a builder for Linux with the same architecture as your Mac (`linux-aarch64`6464-if you are using Apple Silicon).6161+ In order to build Tangled's dev VM on macOS, you will6262+ first need to set up a Linux Nix builder. The recommended6363+ way to do so is to run a [`darwin.linux-builder`6464+ VM](https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder)6565+ and to register it in `nix.conf` as a builder for Linux6666+ with the same architecture as your Mac (`linux-aarch64` if6767+ you are using Apple Silicon).65686666-> IMPORTANT: You must build `darwin.linux-builder` somewhere other than inside6767-> the tangled repo so that it doesn't conflict with the other VM. For example,6868-> you can do6969->7070-> ```shell7171-> cd $(mktemp -d buildervm.XXXXX) && nix run nixpkgs#darwin.linux-builder7272-> ```7373->7474-> to store the builder VM in a temporary dir.7575->7676-> You should read and follow [all the other intructions][darwin builder vm] to7777-> avoid subtle problems.6969+ > IMPORTANT: You must build `darwin.linux-builder` somewhere other than inside7070+ > the tangled repo so that it doesn't conflict with the other VM. For example,7171+ > you can do7272+ >7373+ > ```shell7474+ > cd $(mktemp -d buildervm.XXXXX) && nix run nixpkgs#darwin.linux-builder7575+ > ```7676+ >7777+ > to store the builder VM in a temporary dir.7878+ >7979+ > You should read and follow [all the other intructions][darwin builder vm] to8080+ > avoid subtle problems.78817979-Alternatively, you can use any other method to set up a Linux machine with `nix`8080-installed that you can `sudo ssh` into (in other words, root user on your Mac8181-has to be able to ssh into the Linux machine without entering a password) and8282-that has the same architecture as your Mac. See [remote builder instructions]8383-for how to register such a builder in `nix.conf`.8282+ Alternatively, you can use any other method to set up a8383+ Linux machine with `nix` installed that you can `sudo ssh`8484+ into (in other words, root user on your Mac has to be able8585+ to ssh into the Linux machine without entering a password)8686+ and that has the same architecture as your Mac. See8787+ [remote builder8888+ instructions](https://nix.dev/manual/nix/2.28/advanced-topics/distributed-builds.html#requirements)8989+ for how to register such a builder in `nix.conf`.84908585-> WARNING: If you'd like to use8686-> [`nixos-lima`](https://github.com/nixos-lima/nixos-lima) or8787-> [Orbstack](https://orbstack.dev/), note that setting them up so that `sudo8888-> ssh` works can be tricky. It seems to be [possible with8989-> Orbstack](https://github.com/orgs/orbstack/discussions/1669).9191+ > WARNING: If you'd like to use9292+ > [`nixos-lima`](https://github.com/nixos-lima/nixos-lima) or9393+ > [Orbstack](https://orbstack.dev/), note that setting them up so that `sudo9494+ > ssh` works can be tricky. It seems to be [possible with9595+ > Orbstack](https://github.com/orgs/orbstack/discussions/1669).90969191-[darwin builder vm]:9292- https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder9393-[remote builder instructions]:9494- https://nix.dev/manual/nix/2.28/advanced-topics/distributed-builds.html#requirements 9595-9696-### Running a knot on a dev VM 9797+</details>97989899To begin, grab your DID from http://localhost:3000/settings.99100Then, set `TANGLED_VM_KNOT_OWNER` and100100-`TANGLED_VM_SPINDLE_OWNER` to your DID.101101-102102-If you don't want to [set up a spindle](#running-a-spindle),103103-you can use any placeholder value.104104-105105-You can now start a lightweight NixOS VM like so:101101+`TANGLED_VM_SPINDLE_OWNER` to your DID. You can now start a102102+lightweight NixOS VM like so:106103107104```bash108105nix run --impure .#vm···111114with `ssh` exposed on port 2222.112115113116Once the services are running, head to114114-http://localhost:3000/knots and hit verify (and similarly,115115-http://localhost:3000/spindles to verify your spindle). It116116-should verify the ownership of the services instantly if117117-everything went smoothly.117117+http://localhost:3000/knots and hit verify. It should118118+verify the ownership of the services instantly if everything119119+went smoothly.118120119121You can push repositories to this VM with this ssh config120122block on your main machine:···155159# litecli has a nicer REPL interface:156160litecli /var/lib/spindle/spindle.db157161```162162+163163+If for any reason you wish to disable either one of the164164+services in the VM, modify [nix/vm.nix](/nix/vm.nix) and set165165+`services.tangled-spindle.enable` (or166166+`services.tangled-knot.enable`) to `false`.