From e122ca0006c96b562c62b89fdcdabb633068905e Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 1 Aug 2023 14:21:06 +0200 Subject: [PATCH] Enable console on serial port and print public ssh host key when booting --- configuration/common/default.nix | 18 ++++++++++++++++++ configuration/proxmox-vm/default.nix | 6 ++++++ hosts.nix | 1 - 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/configuration/common/default.nix b/configuration/common/default.nix index 2136658..1b2b085 100644 --- a/configuration/common/default.nix +++ b/configuration/common/default.nix @@ -51,5 +51,23 @@ preliminarySelfsigned = true; }; + # Print the ed25519 public ssh host key to console when booting + systemd.units."print-public-ssh-host-key.service" = { + enable = true; + text = '' + [Unit] + Description=print-public-ssh-host-key.service + Before=getty@tty1.service + + [Service] + Type=oneshot + ExecStart=/run/current-system/sw/bin/bash -c "/run/current-system/sw/bin/echo ----- ED25519 PUBLIC SSH HOST KEY -----\ + && /run/current-system/sw/bin/cut -d ' ' -f 1-2 /etc/ssh/ssh_host_ed25519_key.pub" + RemainAfterExit=no + StandardOutput=tty + ''; + wantedBy = [ "multi-user.target" ]; + }; + services.fstrim.enable = true; } diff --git a/configuration/proxmox-vm/default.nix b/configuration/proxmox-vm/default.nix index 65105c0..47ed7df 100644 --- a/configuration/proxmox-vm/default.nix +++ b/configuration/proxmox-vm/default.nix @@ -1,4 +1,10 @@ { ... }: { + # Enable console output on TTY1 and serial console + boot.kernelParams = [ + "console=tty1" + "console=ttyS0,115200" + ]; + services.qemuGuest.enable = true; } diff --git a/hosts.nix b/hosts.nix index 2ba24de..133f155 100644 --- a/hosts.nix +++ b/hosts.nix @@ -7,7 +7,6 @@ let ./configuration/proxmox-vm/hardware-configuration.nix ]; }; - # generateDefaults = hosts: builtins.mapAttrs (name: { hostNixpkgs ? nixpkgs, system ? "x86_64-linux",