installer: wait for onion hostname to be available

This commit is contained in:
lassulus
2023-07-24 11:31:52 +02:00
parent d99060695f
commit 930f1660e9
2 changed files with 18 additions and 9 deletions

View File

@@ -1,11 +1,17 @@
{ self, lib, ... }: { { self, lib, ... }: {
flake.packages.x86_64-linux = { flake.packages.x86_64-linux =
install-iso = (lib.nixosSystem { let
system = "x86_64-linux"; installer = lib.nixosSystem {
modules = [ system = "x86_64-linux";
self.nixosModules.installer modules = [
self.inputs.nixos-generators.nixosModules.all-formats self.nixosModules.installer
]; self.inputs.nixos-generators.nixosModules.all-formats
}).config.formats.install-iso; ];
}; };
in
{
install-iso = installer.config.formats.install-iso;
install-vm-nogui = installer.config.formats.vm-nogui;
install-vm = installer.config.formats.vm;
};
} }

View File

@@ -7,18 +7,21 @@
]; ];
services.openssh.settings.PermitRootLogin = "yes"; services.openssh.settings.PermitRootLogin = "yes";
system.activationScripts.root-password = '' system.activationScripts.root-password = ''
mkdir -p /var/shared
${pkgs.pwgen}/bin/pwgen -s 16 1 > /var/shared/root-password ${pkgs.pwgen}/bin/pwgen -s 16 1 > /var/shared/root-password
echo "root:$(cat /var/shared/root-password)" | chpasswd echo "root:$(cat /var/shared/root-password)" | chpasswd
''; '';
hidden-announce = { hidden-announce = {
enable = true; enable = true;
script = pkgs.writers.writeDash "write-hostname" '' script = pkgs.writers.writeDash "write-hostname" ''
mkdir -p /var/shared
echo "$1" > /var/shared/onion-hostname echo "$1" > /var/shared/onion-hostname
''; '';
}; };
services.getty.autologinUser = lib.mkForce "root"; services.getty.autologinUser = lib.mkForce "root";
programs.bash.interactiveShellInit = '' programs.bash.interactiveShellInit = ''
if [ "$(tty)" = "/dev/tty1" ]; then if [ "$(tty)" = "/dev/tty1" ]; then
until test -e /var/shared/onion-hostname; do sleep 1; done
echo "ssh://root:$(cat /var/shared/root-password)@$(cat /var/shared/onion-hostname)" echo "ssh://root:$(cat /var/shared/root-password)@$(cat /var/shared/onion-hostname)"
fi fi
''; '';