From b76ad56fc98a03514fa897de6ed72d97a3f7b465 Mon Sep 17 00:00:00 2001 From: Mel Date: Sat, 2 Mar 2024 18:47:17 +0000 Subject: MOTD on SSH login --- configuration.nix | 21 +++++++++++++++++---- me.nix | 4 ++-- util.nix | 13 +++++++++++-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/configuration.nix b/configuration.nix index 81df308..bf8b46c 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,9 +1,9 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let - util = import ./util.nix; + util = import ./util.nix { inherit lib; }; - me = import ./me.nix { inherit util; }; + me = util.checkMe (import ./me.nix); security = import ./security.nix; in { @@ -33,6 +33,14 @@ in hashedPassword = security.password; }; + users.motd = '' + +/^ /^ +\ ' ' 7 < Hi, I'm ${util.titleCase me.name} +/ \ + + ''; + networking = { hostName = me.name; @@ -85,7 +93,12 @@ in vimrcFile = ./configs/.vimrc; }; }; - fish.enable = true; + fish = { + enable = true; + interactiveShellInit = '' + set fish_greeting + ''; + }; git.enable = true; tmux.enable = true; }; diff --git a/me.nix b/me.nix index 7f088d3..e4e8cfa 100644 --- a/me.nix +++ b/me.nix @@ -1,3 +1,3 @@ -{ util, ... }: util.mkMe { +{ name = ""; # Enter machine name here -} \ No newline at end of file +} diff --git a/util.nix b/util.nix index 86fe375..1375ef5 100644 --- a/util.nix +++ b/util.nix @@ -1,5 +1,14 @@ +{ lib }: { - mkMe = { name ? "", ... }@me: + checkMe = { name ? "", ... }@me: assert name != ""; + assert (builtins.pathExists ./machines/${name}.nix) + && (builtins.pathExists ./hardware/${name}.nix); me; -} \ No newline at end of file + + titleCase = str: with lib.strings; let + firstCharUpper = s: concatStrings [(toUpper (substring 0 1 s)) (substring 1 (stringLength s) s)]; + in + concatStringsSep " " (map firstCharUpper (splitString " " str)); + +} -- cgit 1.4.1