diff options
| author | Jakub Stachurski <j.stachurski@student.utwente.nl> | 2026-02-11 15:33:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-11 15:33:46 +0100 |
| commit | f4272650dba86e04863b994bc85165855ac0eb58 (patch) | |
| tree | a6855656f35bc4c351e215827b58a83b4f2a99ec /modules/motd.nix | |
| parent | bb87f9ebadc3bb5c5158d9fbad9a5acef8c8f692 (diff) | |
| parent | 2f65e7f40e97f6ccb3d164169698033ce1692a76 (diff) | |
Merge branch 'main' into host/omega-relayhost/omega-relay
Diffstat (limited to 'modules/motd.nix')
| -rw-r--r-- | modules/motd.nix | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/modules/motd.nix b/modules/motd.nix new file mode 100644 index 0000000..f9f572c --- /dev/null +++ b/modules/motd.nix @@ -0,0 +1,89 @@ +{ pkgs, config, ... }: +let + banner_script = pkgs.writeShellScript "motd_banner.sh" '' + echo "This is a nice banner, property of wilkuu (wilkuu.xyz)" + echo -e "\n\tTODO: Put a banner here\t\n" + echo "Current hostname: ${config.networking.hostName}" + ''; + + # Code stolen from the nix store so I can finish motd_shell + motdConf = + pkgs.runCommand "motd.toml" + { + __structuredAttrs = true; + inherit (config.programs.rust-motd) order settings; + nativeBuildInputs = [ + pkgs.remarshal + pkgs.jq + ]; + } + '' + cat "$NIX_ATTRS_JSON_FILE" \ + | jq '.settings as $settings + | .order + | map({ key: ., value: $settings."\(.)" }) + | from_entries' -r \ + | json2toml /dev/stdin "$out" + ''; + + motd_shell = pkgs.writeShellScriptBin "motd_shell" '' + if [[ -n "$SHOW_MOTD" && -x /run/current-system/sw/bin/rust-motd ]]; then + unset SHOW_MOTD + ${pkgs.rust-motd}/bin/rust-motd ${motdConf} + fi + $1 + ''; +in +{ + environment.systemPackages = with pkgs; [ + rust-motd + motd_shell + ]; + programs.rust-motd = { + enable = true; + order = [ + "banner" + "uptime" + "load_avg" + "filesystems" + "memory" + "last_run" + "global" + ]; + settings = { + banner = { + color = "light_magenta"; + # TODO: Make this nice + command = "bash ${banner_script}"; + }; + uptime = { + prefix = "Uptime: "; + }; + load_avg = { + format = '' + Load: [1m] [5m] [15m] + {one:.02} , {five:.02} , {fifteen:.02} + ''; + }; + filesystems = { + root = "/"; + store = "/store2"; + ntfs = "/win_games"; + }; + memory = { + swap_pos = "beside"; + }; + last_run = { }; + }; + }; + security.pam.services.kitty = { + showMotd = true; + }; + security.pam.services.kitty-wrapper = { + showMotd = true; + }; + security.pam.services.login = { + showMotd = true; + }; + +} |
