Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicegginton committed Dec 31, 2024
1 parent 2385919 commit f616185
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 5 deletions.
15 changes: 15 additions & 0 deletions :w
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ lib, writeShellScriptBin, ensure-user-is-root, iproute2, coreutils, gnugrep, nettools, gum }:

let
paths = lib.makeBinPath [ ensure-user-is-root iproute2 coreutils gnugrep nettools gum ];
in

writeShellScriptBin "host-status" ''
export PATH=${paths}
set -efu -o pipefail
msgs=()
msgs+=("Network is up: $(if [ -n "$(ip -brief -color addr)" ]; then echo "yes"; else echo "no"; fi)")
msgs+=("Local network addresses: $(ip -brief -color addr | grep -v "lo" | awk '{print $3}')")
msgs+=("Multicast DNS: $(hostname).local")
gum join --vertical "''${msgs[@]}"
''
8 changes: 7 additions & 1 deletion hosts/nixos/minimal-iso.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{ inputs, modulesPath, pkgs, ... }:
{ inputs, modulesPath, pkgs, lib, ... }:

{
imports = [
"${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
inputs.nixos-images.nixosModules.image-installer
];
nix.settings.experimental-features = "nix-command flakes";
programs.bash.interactiveShellInit = ''
if [[ "$(tty)" =~ /dev/(tty1|hvc0|ttyS0)$ ]]; then
systemctl restart systemd-vconsole-setup.service
${pkgs.host-status}/bin/host-status --root-password
fi
'';
services.openssh.enable = true;
environment.systemPackages = with pkgs; [ fuse bottom ];
}
3 changes: 2 additions & 1 deletion modules/nixos/console.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{ config, ... }:
{ config, lib, pkgs, ... }:

{
config = {
console.enable = true;
console.earlySetup = true;
console.keyMap = "uk";
console.font = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u22n.psf.gz";
console.colors = config.scheme.toList;
};
}
1 change: 1 addition & 0 deletions modules/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ with lib;
pinentry
pinentry-curses
collect-garbage
host-status
secrets-sync
];
};
Expand Down
2 changes: 1 addition & 1 deletion modules/nixos/zsh.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_:
{ pkgs, ... }:

{
config = {
Expand Down
1 change: 1 addition & 0 deletions overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rec {
export-aws-credentials = final.callPackage ./pkgs/export-aws-credentials.nix { };
gpg-import-keys = final.callPackage ./pkgs/gpg-import-keys.nix { };
install-nixos = final.callPackage ./pkgs/install-nixos.nix { };
host-status = final.callPackage ./pkgs/host-status.nix { };
network-filters-disable = final.callPackage ./pkgs/network-filters-disable.nix { };
network-filters-enable = final.callPackage ./pkgs/network-filters-enable.nix { };
nodejs-shell-setup-hook = final.callPackage ./pkgs/nodejs-shell-setup-hook.nix { };
Expand Down
3 changes: 1 addition & 2 deletions pkgs/bootstrap-nixos-host.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ writeShellApplication {
chmod 600 "$temp/run/bitwarden-secrets/$name"
done
msg=()
msg+=("$(gum style --foreground=111 --align=center --width=50 --margin="1 2" --padding="2 4" "NixOS")")
msg+=("")
msgs+=("$(gum style --foreground=111 --align=center --margin="1 0" "NixOS")")
msg+=("Hostname: $hostname")
msg+=("Installer IP: $installer_ip")
msg+=( "Build target: $build_target" )
Expand Down
21 changes: 21 additions & 0 deletions pkgs/host-status.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ lib, writeShellScriptBin, coreutils, busybox, gum }:

let
paths = lib.makeBinPath [ coreutils busybox gum ];
in

writeShellScriptBin "host-status" ''
export PATH=${paths}
set -efu -o pipefail
ld=$(ip -brief -color addr | awk '{print $3}' | grep -v "lo" | grep -v "127" | tr "\n" " ")
msgs=()
msgs+=("$(gum style --foreground=111 --align=center --margin="1 0" "NixOS")")
user=$(whoami)
if [ "$user" = "root" && -f /var/shared/root-password ]; then
msgs+=("Root password: $(cat /var/shared/root-password)")
fi
msgs+=("Hostname: $(hostname)")
msgs+=("Local addresses: $ld")
msgs+=("Multicast DNS: $(hostname).local")
gum style --border-foreground=111 --border normal "''${msgs[@]}"
''

0 comments on commit f616185

Please sign in to comment.