···11+# hacking on tangled
22+33+We highly recommend [installing
44+nix](https://nixos.org/download/) (the package manager)
55+before working on the codebase. The nix flake provides a lot
66+of helpers to get started and most importantly, builds and
77+dev shells are entirely deterministic.
88+99+To set up your dev environment:
1010+1111+```bash
1212+nix develop
1313+```
1414+1515+Non-nix users can look at the `devShell` attribute in the
1616+`flake.nix` file to determine necessary dependencies.
1717+1818+## running the appview
1919+2020+The nix flake also exposes a few `app` attributes (run `nix
2121+flake show` to see a full list of what the flake provides),
2222+one of the apps runs the appview with the `air`
2323+live-reloader:
2424+2525+```bash
2626+TANGLED_DEV=true nix run .#watch-appview
2727+2828+# TANGLED_DB_PATH might be of interest to point to
2929+# different sqlite DBs
3030+3131+# in a separate shell, you can live-reload tailwind
3232+nix run .#watch-tailwind
3333+```
3434+3535+## running a knotserver
3636+3737+An end-to-end knotserver setup requires setting up a machine
3838+with `sshd`, `repoguard`, `keyfetch`, a git user, which is
3939+quite cumbersome and so the nix flake provides a
4040+`nixosConfiguration` to do so.
4141+4242+To begin, head to `http://localhost:3000` in the browser and
4343+generate a knotserver secret. Replace the existing secret in
4444+`flake.nix` with the newly generated secret.
4545+4646+You can now start a lightweight NixOS VM using
4747+`nixos-shell` like so:
4848+4949+```bash
5050+QEMU_NET_OPTS="hostfwd=tcp::6000-:6000,hostfwd=tcp::2222-:22" nixos-shell --flake .#knotVM
5151+5252+# hit Ctrl-a + c + q to exit the VM
5353+```
5454+5555+This starts a knotserver on port 6000 with `ssh` exposed on
5656+port 2222. You can push repositories to this VM with this
5757+ssh config block on your main machine:
5858+5959+```bash
6060+Host nixos-shell
6161+ Hostname localhost
6262+ Port 2222
6363+ User git
6464+ IdentityFile ~/.ssh/my_tangled_key
6565+```
6666+6767+Set up a remote called `local-dev` on a git repo:
6868+6969+```bash
7070+git remote add local-dev git@nixos-shell:user/repo
7171+git push local-dev main
7272+```