From 9007b42d93c7898cdbd2ea04cbe3fd68956683ea Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Thu, 20 Jun 2024 15:48:18 +0700 Subject: [PATCH] rust-motd: added configuration for rust-motd service --- options/services.nix | 1 + profiles/homeserver.nix | 1 + system/services/default.nix | 13 ++++----- system/services/rust-motd.nix | 50 +++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 system/services/rust-motd.nix diff --git a/options/services.nix b/options/services.nix index 885e65f..f6c5cf4 100644 --- a/options/services.nix +++ b/options/services.nix @@ -14,5 +14,6 @@ in openvpn.enable = mkEnableOption "openvpn"; stubby.enable = mkEnableOption "stubby"; jellyfin.enable = mkEnableOption "jellyfin"; + rust-motd.enable = mkEnableOption "rust-motd"; }; } diff --git a/profiles/homeserver.nix b/profiles/homeserver.nix index 5f70888..b6d65fd 100644 --- a/profiles/homeserver.nix +++ b/profiles/homeserver.nix @@ -48,6 +48,7 @@ openvpn.enable = true; stubby.enable = true; jellyfin.enable = true; + rust-motd.enable = true; }; }; } diff --git a/system/services/default.nix b/system/services/default.nix index 6cf0c39..c2dcec0 100644 --- a/system/services/default.nix +++ b/system/services/default.nix @@ -4,12 +4,13 @@ ./caddy.nix ./cockpit.nix ./forgejo.nix - ./samba.nix - ./nextcloud.nix - ./syncthing.nix - ./kavita.nix - ./openvpn.nix - ./stubby.nix ./jellyfin.nix + ./kavita.nix + ./nextcloud.nix + ./openvpn.nix + ./rust-motd.nix + ./samba.nix + ./stubby.nix + ./syncthing.nix ]; } diff --git a/system/services/rust-motd.nix b/system/services/rust-motd.nix new file mode 100644 index 0000000..2a716ca --- /dev/null +++ b/system/services/rust-motd.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.profile.services.rust-motd; + inherit (lib) mkIf mkMerge; +in +{ + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + fail2ban + ]; + programs.rust-motd = { + enable = true; + settings = { + banner = { + color = "white"; + command = "${pkgs.fortune-kind}/bin/fortune-kind | ${pkgs.neo-cowsay}/bin/cowsay --random"; + }; + service_status = mkMerge [ + { } + (mkIf config.profile.podman.pihole.enable { Pihole = "podman-pihole"; }) + (mkIf config.profile.podman.qbittorrent.enable { QBittorrent = "podman-qbittorrent"; }) + (mkIf config.profile.services.forgejo.enable { Forgejo = "forgejo"; }) + ]; + uptime = { + prefix = "Up"; + }; + filesystems = { + Root = "/"; + NAS = "/nas"; + }; + memory = { + swap_pos = "beside"; + }; + last_login = { + ${config.profile.user.name} = 1; + }; + last_run = { }; + }; + order = [ + "banner" + "last_login" + "uptime" + "memory" + "service_status" + "filesystems" + "last_run" + ]; + }; + }; +}