···4848redis-server
4949```
50505151-## running knots and spindles in a VM
5151+## running knots and spindles
52525353An end-to-end knot setup requires setting up a machine with
5454`sshd`, `AuthorizedKeysCommand`, and git user, which is
5555quite cumbersome. So the nix flake provides a
5656`nixosConfiguration` to do so.
57575858-### Mac-specific: setting up a Nix builder
5858+<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 a
6161-Linux Nix builder. The recommended way to do so is to run a
6262-[`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 will
6262+ first need to set up a Linux Nix builder. The recommended
6363+ 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 Linux
6666+ with the same architecture as your Mac (`linux-aarch64` if
6767+ you are using Apple Silicon).
65686666-> IMPORTANT: You must build `darwin.linux-builder` somewhere other than inside
6767-> the tangled repo so that it doesn't conflict with the other VM. For example,
6868-> you can do
6969->
7070-> ```shell
7171-> cd $(mktemp -d buildervm.XXXXX) && nix run nixpkgs#darwin.linux-builder
7272-> ```
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] to
7777-> avoid subtle problems.
6969+ > IMPORTANT: You must build `darwin.linux-builder` somewhere other than inside
7070+ > the tangled repo so that it doesn't conflict with the other VM. For example,
7171+ > you can do
7272+ >
7373+ > ```shell
7474+ > cd $(mktemp -d buildervm.XXXXX) && nix run nixpkgs#darwin.linux-builder
7575+ > ```
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] to
8080+ > 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 Mac
8181-has to be able to ssh into the Linux machine without entering a password) and
8282-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 a
8383+ Linux machine with `nix` installed that you can `sudo ssh`
8484+ into (in other words, root user on your Mac has to be able
8585+ to ssh into the Linux machine without entering a password)
8686+ and that has the same architecture as your Mac. See
8787+ [remote builder
8888+ 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 use
8686-> [`nixos-lima`](https://github.com/nixos-lima/nixos-lima) or
8787-> [Orbstack](https://orbstack.dev/), note that setting them up so that `sudo
8888-> ssh` works can be tricky. It seems to be [possible with
8989-> Orbstack](https://github.com/orgs/orbstack/discussions/1669).
9191+ > WARNING: If you'd like to use
9292+ > [`nixos-lima`](https://github.com/nixos-lima/nixos-lima) or
9393+ > [Orbstack](https://orbstack.dev/), note that setting them up so that `sudo
9494+ > ssh` works can be tricky. It seems to be [possible with
9595+ > Orbstack](https://github.com/orgs/orbstack/discussions/1669).
90969191-[darwin builder vm]:
9292- https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder
9393-[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` and
100100-`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 a
102102+lightweight NixOS VM like so:
106103107104```bash
108105nix run --impure .#vm
···114111with `ssh` exposed on port 2222.
115112116113Once the services are running, head to
117117-http://localhost:3000/knots and hit verify (and similarly,
118118-http://localhost:3000/spindles to verify your spindle). It
119119-should verify the ownership of the services instantly if
120120-everything went smoothly.
114114+http://localhost:3000/knots and hit verify. It should
115115+verify the ownership of the services instantly if everything
116116+went smoothly.
121117122118You can push repositories to this VM with this ssh config
123119block on your main machine:
···159155# litecli has a nicer REPL interface:
160156litecli /var/lib/spindle/spindle.db
161157```
158158+159159+If for any reason you wish to disable either one of the
160160+services in the VM, modify [nix/vm.nix](/nix/vm.nix) and set
161161+`services.tangled-spindle.enable` (or
162162+`services.tangled-knot.enable`) to `false`.