1# hacking on tangled
2
3We highly recommend [installing
4nix](https://nixos.org/download/) (the package manager)
5before working on the codebase. The nix flake provides a lot
6of helpers to get started and most importantly, builds and
7dev shells are entirely deterministic.
8
9To set up your dev environment:
10
11```bash
12nix develop
13```
14
15Non-nix users can look at the `devShell` attribute in the
16`flake.nix` file to determine necessary dependencies.
17
18## running the appview
19
20The nix flake also exposes a few `app` attributes (run `nix
21flake show` to see a full list of what the flake provides),
22one of the apps runs the appview with the `air`
23live-reloader:
24
25```bash
26TANGLED_DEV=true nix run .#watch-appview
27
28# TANGLED_DB_PATH might be of interest to point to
29# different sqlite DBs
30
31# in a separate shell, you can live-reload tailwind
32nix run .#watch-tailwind
33```
34
35## running a knot
36
37An end-to-end knot setup requires setting up a machine with
38`sshd`, `AuthorizedKeysCommand`, and git user, which is
39quite cumbersome. So the nix flake provides a
40`nixosConfiguration` to do so.
41
42To begin, head to `http://localhost:3000` in the browser and
43generate a knot secret. Replace the existing secret in
44`flake.nix` with the newly generated secret.
45
46You can now start a lightweight NixOS VM using
47`nixos-shell` like so:
48
49```bash
50nix run .#vm
51# or nixos-shell --flake .#vm
52
53# hit Ctrl-a + c + q to exit the VM
54```
55
56This starts a knot on port 6000, a spindle on port 6555
57with `ssh` exposed on port 2222. You can push repositories
58to this VM with this ssh config block on your main machine:
59
60```bash
61Host nixos-shell
62 Hostname localhost
63 Port 2222
64 User git
65 IdentityFile ~/.ssh/my_tangled_key
66```
67
68Set up a remote called `local-dev` on a git repo:
69
70```bash
71git remote add local-dev git@nixos-shell:user/repo
72git push local-dev main
73```