···16*.rdb
17.envrc
18# Created if following hacking.md
19-genjwks.out0
···16*.rdb
17.envrc
18# Created if following hacking.md
19+genjwks.out
20+/nix/vm-data
+4-6
docs/hacking.md
···64You will also need to set the `$TANGLED_VM_SPINDLE_OWNER`
65variable to some value. If you don't want to [set up a
66spindle](#running-a-spindle), you can use any placeholder
67-value.
6869-You can now start a lightweight NixOS VM using
70-`nixos-shell` like so:
7172```bash
73-nix run .#vm
74-# or nixos-shell --flake .#vm
7576-# hit Ctrl-a + c + q to exit the VM
77```
7879This starts a knot on port 6000, a spindle on port 6555
···64You will also need to set the `$TANGLED_VM_SPINDLE_OWNER`
65variable to some value. If you don't want to [set up a
66spindle](#running-a-spindle), you can use any placeholder
67+value.
6869+You can now start a lightweight NixOS VM like so:
07071```bash
72+nix run --impure .#vm
07374+# type `poweroff` at the shell to exit the VM
75```
7677This starts a knot on port 6000, a spindle on port 6555
+22-27
flake.nix
···175 program = ''${tailwind-watcher}/bin/run'';
176 };
177 vm = let
178- system =
179 if pkgs.stdenv.hostPlatform.isAarch64
180- then "aarch64"
181- else "x86_64";
182-183- nixos-shell = pkgs.nixos-shell.overrideAttrs (old: {
184- patches =
185- (old.patches or [])
186- ++ [
187- # https://github.com/Mic92/nixos-shell/pull/94
188- (pkgs.fetchpatch {
189- name = "fix-foreign-vm.patch";
190- url = "https://github.com/Mic92/nixos-shell/commit/113e4cc55ae236b5b0b1fbd8b321e9b67c77580e.patch";
191- hash = "sha256-eauetBK0wXAOcd9PYbExokNCiwz2QyFnZ4FnwGi9VCo=";
192- })
193- ];
194- });
195 in {
196 type = "app";
197- program = toString (pkgs.writeShellScript "vm" ''
198- ${nixos-shell}/bin/nixos-shell --flake .#vm-${system} --guest-system ${system}-linux
199- '');
0000000000000000200 };
201 gomod2nix = {
202 type = "app";
···257 imports = [./nix/modules/spindle.nix];
258259 services.tangled-spindle.package = lib.mkDefault self.packages.${pkgs.system}.spindle;
260- };
261- nixosConfigurations.vm-x86_64 = import ./nix/vm.nix {
262- inherit self nixpkgs;
263- system = "x86_64-linux";
264- };
265- nixosConfigurations.vm-aarch64 = import ./nix/vm.nix {
266- inherit self nixpkgs;
267- system = "aarch64-linux";
268 };
269 };
270}
···175 program = ''${tailwind-watcher}/bin/run'';
176 };
177 vm = let
178+ guestSystem =
179 if pkgs.stdenv.hostPlatform.isAarch64
180+ then "aarch64-linux"
181+ else "x86_64-linux";
0000000000000182 in {
183 type = "app";
184+ program =
185+ (pkgs.writeShellApplication {
186+ name = "launch-vm";
187+ text = ''
188+ rootDir=$(jj --ignore-working-copy root || git rev-parse --show-toplevel) || (echo "error: can't find repo root?"; exit 1)
189+ cd "$rootDir"
190+191+ mkdir -p nix/vm-data/{knot,repos,spindle,spindle-logs}
192+193+ export TANGLED_VM_DATA_DIR="$rootDir/nix/vm-data"
194+ exec ${pkgs.lib.getExe
195+ (import ./nix/vm.nix {
196+ inherit nixpkgs self;
197+ system = guestSystem;
198+ hostSystem = system;
199+ }).config.system.build.vm}
200+ '';
201+ })
202+ + /bin/launch-vm;
203 };
204 gomod2nix = {
205 type = "app";
···260 imports = [./nix/modules/spindle.nix];
261262 services.tangled-spindle.package = lib.mkDefault self.packages.${pkgs.system}.spindle;
00000000263 };
264 };
265}