Skip to content

Commit

Permalink
print base port when starting VM
Browse files Browse the repository at this point in the history
  • Loading branch information
tek committed Sep 26, 2023
1 parent 74fffdf commit 0e2d606
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/doc/prose.nix
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ in {
```
$ nix develop .#example
>>> Starting VM
>>> Starting VM with base port 20000
>>> Waiting 30 seconds for VM to boot...
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.4.3
Expand Down
6 changes: 3 additions & 3 deletions lib/vm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ let
display = vm:
if vm.headless then "-display none" else "";

ensure = vm: pkgs.writeScript "ensure-vm" ''
ensure = basePort: vm: pkgs.writeScript "ensure-vm" ''
#!${pkgs.zsh}/bin/zsh
if ${pkgs.procps}/bin/pgrep -F ${vm.pidfile} -L -f ${vm.pidfile} &>/dev/null
then
print '>>> VM already running' >&2
else
print '>>> Starting VM' >&2
print '>>> Starting VM with base port ${toString basePort}' >&2
mkdir -p ${vm.dir}
rm -f ${vm.pidfile}
${vm.derivation}/bin/run-nixos-vm ${display vm} -daemonize -pidfile ${vm.pidfile} -monitor unix:${vm.monitor},server,nowait
Expand All @@ -30,5 +30,5 @@ let
'';

in {
inherit create postgres ensure kill;
inherit create ensure kill;
}
2 changes: 1 addition & 1 deletion modules/env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ in {
in (lib.nixosSystem nixosArgs).config.system.build.vm
);

setup = mkDefault "${vmLib.ensure config.vm}";
setup = mkDefault "${vmLib.ensure config.basePort config.vm}";
exit = mkDefault "${vmLib.kill config.vm}";

};
Expand Down

0 comments on commit 0e2d606

Please sign in to comment.