From e0cec882d86e262ddf4d2a4e0daa17052692c7a9 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 30 Jul 2024 10:36:17 +0200 Subject: [PATCH] feat(console): Add motd with system info --- modules/dgn-console.nix | 50 +++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/modules/dgn-console.nix b/modules/dgn-console.nix index 0a852e9..1bab5af 100644 --- a/modules/dgn-console.nix +++ b/modules/dgn-console.nix @@ -36,7 +36,37 @@ in environment.variables.EDITOR = "nvim"; - programs.neovim.vimAlias = true; + programs = { + neovim.vimAlias = true; + rust-motd = { + enable = true; + + settings = { + uptime.prefix = "Up"; + filesystems.root = "/"; + memory.swap_pos = "below"; + last_login.root = 5; + }; + }; + + bash.promptInit = '' + FQDN="$(hostname).$(domainname)" + # Provide a nice prompt if the terminal supports it. + if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then + PROMPT_COLOR="1;31m" + ((UID)) && PROMPT_COLOR="1;32m" + if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then + # Emacs term mode doesn't support xterm title escape sequence (\e]0;) + PS1="\n\[\033[$PROMPT_COLOR\][\u@$FQDN:\w]\\$\[\033[0m\] " + else + PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\H: \w\a\]\u@$FQDN:\w]\\$\[\033[0m\] " + fi + if test "$TERM" = "xterm"; then + PS1="\[\033]2;$FQDN:\u:\w\007\]$PS1" + fi + fi + ''; + }; system.activationScripts.diff = { supportsDryActivation = true; @@ -45,24 +75,6 @@ in ''; }; - programs.bash.promptInit = '' - FQDN="$(hostname).$(domainname)" - # Provide a nice prompt if the terminal supports it. - if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then - PROMPT_COLOR="1;31m" - ((UID)) && PROMPT_COLOR="1;32m" - if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then - # Emacs term mode doesn't support xterm title escape sequence (\e]0;) - PS1="\n\[\033[$PROMPT_COLOR\][\u@$FQDN:\w]\\$\[\033[0m\] " - else - PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\H: \w\a\]\u@$FQDN:\w]\\$\[\033[0m\] " - fi - if test "$TERM" = "xterm"; then - PS1="\[\033]2;$FQDN:\u:\w\007\]$PS1" - fi - fi - ''; - hardware.enableRedistributableFirmware = true; environment.systemPackages =