commit 4891716c441779c731d37850f7e5ff70e6380b00
parent 80e3814f6d372a7a71818366a5f5fd5ddac8da8d
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Wed, 22 Jul 2026 21:53:17 +0200
parent 80e3814f6d372a7a71818366a5f5fd5ddac8da8d
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Wed, 22 Jul 2026 21:53:17 +0200
nixos/zpha/profile/zaphyra: fancy MotD generator with fops! (and useful informations...)
1 file changed, 57 insertions(+), 10 deletions(-)
M
|
67
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
diff --git a/nixosModules/zpha/profiles/zaphyra.nix b/nixosModules/zpha/profiles/zaphyra.nix @@ -47,18 +47,65 @@ in ../../../maidModules/programs/lazygit.nix ]; - users.users = { - root = { - extraGroups = [ "ssh" ]; - openssh.authorizedKeys.keys = [ - (builtins.readFile "${pkgs.zpha.website}/ssh_pubkey.asc") - ]; - }; - zaphyra.maid = { - programs = { - starship.enable = true; + users = { + users = { + root = { + extraGroups = [ "ssh" ]; + openssh.authorizedKeys.keys = [ + (builtins.readFile "${pkgs.zpha.website}/ssh_pubkey.asc") + ]; + }; + zaphyra.maid = { + programs = { + starship.enable = true; + }; }; }; + motdFile = "/run/motd"; + }; + systemd.services.motd-generator = { + before = [ "sysinit-reactivation.target" ]; + wantedBy = [ + "sysinit-reactivation.target" + "multi-user.target" + ]; + script = + let + distro = "${config.system.nixos.distroName} ${config.system.nixos.version}"; + deployDate = "`TZ=UTC date --date=@$(stat -c %W /nix/var/nix/profiles/system) +'%Y-%m-%d %H:%M'` (UTC)"; + lastCommitRev = self.dirtyShortRev or self.shortRev; + lastCommitDate = + with lib.strings; + let + date = self.lastModifiedDate; + year = substring 0 4 date; + month = substring 4 2 date; + day = substring 6 2 date; + hour = substring 8 2 date; + minute = substring 10 2 date; + in + "${year}-${month}-${day} ${hour}:${minute} (UTC)"; + commitText = lib.optionalString ( + self ? rev + ) "..was built from: ${lastCommitRev} [${lastCommitDate}]"; + commitWarning = lib.optionalString ( + self ? dirtyRev + ) "This system was built with uncommited changes! Please remember to commit them!"; + in + '' + cat << EOF > /run/motd + ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀ + ⠀⠀⠀⠀⠀⠀⠀⣤⣄⣀⠀⠀⠀⠀⠀⣠⣿⡇⠀⠀ + ⠀⠀⠀⠀⠀⠤⢶⣬⣿⣿⣷⣾⣂⣀⣴⣿⣿⡇⠀⠀Welcome on ${config.networking.fqdn} + ⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀This system... + ⠀⠀⠀⣼⣿⠁⠀⢹⣿⣿⡏⠀⠈⢿⣿⣿⣿⠀⠀⠀..is running: ${distro} + ⠀⠀⢠⣿⣿⣄⣀⡼⠛⢿⣷⣄⣠⣿⣿⣿⣿⡆⠀⠀..was deployed at: ${deployDate} + ⠀⠀⢸⣿⣿⣿⠻⡷⠒⢾⣿⠟⣻⣿⣿⣿⣿⡇⠀⠀${commitText} + ⠀⠀⠀⢿⣿⣿⣦⣠⣶⣄⣠⣾⣿⣿⣿⣿⣿⠇⠀⠀${commitWarning} + ⠀⠀⠀⠈⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠋⠀⠀⠀ + + EOF + ''; }; zpha = {