forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
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 50QEMU_NET_OPTS="hostfwd=tcp::6000-:6000,hostfwd=tcp::2222-:22" nixos-shell --flake .#knotVM 51 52# hit Ctrl-a + c + q to exit the VM 53``` 54 55This starts a knot on port 6000 with `ssh` exposed on port 562222. You can push repositories to this VM with this ssh 57config block on your main machine: 58 59```bash 60Host nixos-shell 61 Hostname localhost 62 Port 2222 63 User git 64 IdentityFile ~/.ssh/my_tangled_key 65``` 66 67Set up a remote called `local-dev` on a git repo: 68 69```bash 70git remote add local-dev git@nixos-shell:user/repo 71git push local-dev main 72```