···5656`nixosConfiguration` to do so.57575858To begin, head to `http://localhost:3000/knots` in the browser5959-and generate a knot secret. Replace the existing secret in6060-`nix/vm.nix` (`KNOT_SERVER_SECRET`) with the newly generated6161-secret.5959+and generate a knot secret. Set `$TANGLED_KNOT_SECRET` to it,6060+ideally in a `.envrc` with [direnv](https://direnv.net) so you6161+don't lose it.62626363You can now start a lightweight NixOS VM using6464`nixos-shell` like so:···91919292## running a spindle93939494-Be sure to change the `owner` field for the spindle in9595-`nix/vm.nix` to your own DID. The above VM should already9696-be running a spindle on `localhost:6555`. You can head to9797-the spindle dashboard on `http://localhost:3000/spindles`,9898-and register a spindle with hostname `localhost:6555`. It9999-should instantly be verified. You can then configure each100100-repository to use this spindle and run CI jobs.9494+Be sure to set `$TANGLED_SPINDLE_OWNER` to your own DID.9595+The above VM should already be running a spindle on `localhost:6555`.9696+You can head to the spindle dashboard on `http://localhost:3000/spindles`,9797+and register a spindle with hostname `localhost:6555`. It should instantly9898+be verified. You can then configure each repository to use this spindle9999+and run CI jobs.101100102101Of interest when debugging spindles:103102
+73-66
nix/vm.nix
···22 nixpkgs,33 system,44 self,55-}:66-nixpkgs.lib.nixosSystem {77- inherit system;88- modules = [99- self.nixosModules.knot1010- self.nixosModules.spindle1111- ({1212- config,1313- pkgs,1414- ...1515- }: {1616- virtualisation = {1717- memorySize = 2048;1818- diskSize = 10 * 1024;1919- cores = 2;2020- forwardPorts = [2121- # ssh2222- {2323- from = "host";2424- host.port = 2222;2525- guest.port = 22;2626- }2727- # knot2828- {2929- from = "host";3030- host.port = 6000;3131- guest.port = 6000;3232- }3333- # spindle3434- {3535- from = "host";3636- host.port = 6555;3737- guest.port = 6555;3838- }3939- ];4040- };4141- services.getty.autologinUser = "root";4242- environment.systemPackages = with pkgs; [curl vim git];4343- systemd.tmpfiles.rules = let4444- u = config.services.tangled-knot.gitUser;4545- g = config.services.tangled-knot.gitUser;4646- in [4747- "d /var/lib/knot 0770 ${u} ${g} - -" # Create the directory first4848- "f+ /var/lib/knot/secret 0660 ${u} ${g} - KNOT_SERVER_SECRET=168c426fa6d9829fcbe85c96bdf144e800fb9737d6ca87f21acc543b1aa3e440"4949- ];5050- services.tangled-knot = {5151- enable = true;5252- motd = "Welcome to the development knot!\n";5353- server = {5454- secretFile = "/var/lib/knot/secret";5555- hostname = "localhost:6000";5656- listenAddr = "0.0.0.0:6000";55+}: let66+ envVar = name: let77+ var = builtins.getEnv name;88+ in99+ if var == ""1010+ then throw "\$${name} must be defined, see docs/hacking.md for more details"1111+ else var;1212+in1313+ nixpkgs.lib.nixosSystem {1414+ inherit system;1515+ modules = [1616+ self.nixosModules.knot1717+ self.nixosModules.spindle1818+ ({1919+ config,2020+ pkgs,2121+ ...2222+ }: {2323+ virtualisation = {2424+ memorySize = 2048;2525+ diskSize = 10 * 1024;2626+ cores = 2;2727+ forwardPorts = [2828+ # ssh2929+ {3030+ from = "host";3131+ host.port = 2222;3232+ guest.port = 22;3333+ }3434+ # knot3535+ {3636+ from = "host";3737+ host.port = 6000;3838+ guest.port = 6000;3939+ }4040+ # spindle4141+ {4242+ from = "host";4343+ host.port = 6555;4444+ guest.port = 6555;4545+ }4646+ ];5747 };5858- };5959- services.tangled-spindle = {6060- enable = true;6161- server = {6262- owner = "did:plc:qfpnj4og54vl56wngdriaxug";6363- hostname = "localhost:6555";6464- listenAddr = "0.0.0.0:6555";6565- dev = true;6666- secrets = {6767- provider = "sqlite";4848+ services.getty.autologinUser = "root";4949+ environment.systemPackages = with pkgs; [curl vim git];5050+ systemd.tmpfiles.rules = let5151+ u = config.services.tangled-knot.gitUser;5252+ g = config.services.tangled-knot.gitUser;5353+ in [5454+ "d /var/lib/knot 0770 ${u} ${g} - -" # Create the directory first5555+ "f+ /var/lib/knot/secret 0660 ${u} ${g} - KNOT_SERVER_SECRET=${envVar "TANGLED_VM_KNOT_SECRET"}"5656+ ];5757+ services.tangled-knot = {5858+ enable = true;5959+ motd = "Welcome to the development knot!\n";6060+ server = {6161+ secretFile = "/var/lib/knot/secret";6262+ hostname = "localhost:6000";6363+ listenAddr = "0.0.0.0:6000";6864 };6965 };7070- };7171- })7272- ];7373-}6666+ services.tangled-spindle = {6767+ enable = true;6868+ server = {6969+ owner = envVar "TANGLED_VM_SPINDLE_OWNER";7070+ hostname = "localhost:6555";7171+ listenAddr = "0.0.0.0:6555";7272+ dev = true;7373+ secrets = {7474+ provider = "sqlite";7575+ };7676+ };7777+ };7878+ })7979+ ];8080+ }