From 697a9f2cabb4a7699bb747bcc87d6ada86100183 Mon Sep 17 00:00:00 2001 From: William Date: Mon, 3 Nov 2025 10:55:14 -0300 Subject: [PATCH] wrap fastfetch with config; run fastfetch on ssh login --- hosts/modules/common/openssh.nix | 5 ++ hosts/modules/common/programs.nix | 2 +- hosts/modules/common/users.nix | 6 --- overlays.nix | 5 +- packages.nix | 5 +- packages/fastfetch.nix | 81 +++++++++++++++++++++++++++++++ 6 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 packages/fastfetch.nix diff --git a/hosts/modules/common/openssh.nix b/hosts/modules/common/openssh.nix index 07108ce..63422b3 100644 --- a/hosts/modules/common/openssh.nix +++ b/hosts/modules/common/openssh.nix @@ -5,4 +5,9 @@ enable = true; settings.PermitRootLogin = "no"; }; + programs.fish.interactiveShellInit = '' + if set -q SSH_CONNECTION + neofetch + end + ''; } diff --git a/hosts/modules/common/programs.nix b/hosts/modules/common/programs.nix index e0cc2c9..be57b69 100644 --- a/hosts/modules/common/programs.nix +++ b/hosts/modules/common/programs.nix @@ -7,6 +7,7 @@ git ### System Utilities ### btop + fastfetch helix nixos-firewall-tool nvd @@ -18,7 +19,6 @@ shellAliases = { cat = "${lib.getExe pkgs.bat} --paging=never --style=plain"; ls = "${lib.getExe pkgs.eza} --icons --group-directories-first"; - neofetch = "${lib.getExe pkgs.fastfetch}"; tree = "ls --tree"; }; }; diff --git a/hosts/modules/common/users.nix b/hosts/modules/common/users.nix index 076eb99..0572153 100644 --- a/hosts/modules/common/users.nix +++ b/hosts/modules/common/users.nix @@ -20,10 +20,4 @@ hashedPassword = "!"; }; }; - programs.fish = { - enable = true; - interactiveShellInit = '' - set fish_greeting - ''; - }; } diff --git a/overlays.nix b/overlays.nix index 2732f0e..eab4edf 100644 --- a/overlays.nix +++ b/overlays.nix @@ -3,10 +3,11 @@ { flake.overlays = { default = final: prev: { - toggleaudiosink = inputs.self.packages.${final.system}.toggleaudiosink; + base16-schemes = inputs.self.packages.${final.system}.base16-schemes; + fastfetch = inputs.self.packages.${final.system}.fastfetch; hm-cli = inputs.self.packages.${final.system}.hm-cli; kwrite = inputs.self.packages.${final.system}.kwrite; - base16-schemes = inputs.self.packages.${final.system}.base16-schemes; + toggleaudiosink = inputs.self.packages.${final.system}.toggleaudiosink; }; }; } diff --git a/packages.nix b/packages.nix index 2cd7661..46979f8 100644 --- a/packages.nix +++ b/packages.nix @@ -5,10 +5,11 @@ { pkgs, system, ... }: { packages = { - toggleaudiosink = pkgs.callPackage ./packages/toggleaudiosink.nix { }; + base16-schemes = pkgs.callPackage ./packages/base16-schemes.nix { }; + fastfetch = pkgs.callPackage ./packages/fastfetch.nix { }; hm-cli = pkgs.callPackage ./packages/hm-cli.nix { }; kwrite = pkgs.callPackage ./packages/kwrite.nix { }; - base16-schemes = pkgs.callPackage ./packages/base16-schemes.nix { }; + toggleaudiosink = pkgs.callPackage ./packages/toggleaudiosink.nix { }; }; }; } diff --git a/packages/fastfetch.nix b/packages/fastfetch.nix new file mode 100644 index 0000000..fa8e0ea --- /dev/null +++ b/packages/fastfetch.nix @@ -0,0 +1,81 @@ +{ + lib, + pkgs ? import { }, +}: + +let + fastfetch-logo = pkgs.fetchurl { + url = "https://discourse.nixos.org/uploads/default/original/3X/3/6/36954e6d6aa32c8b00f50ca43f142d898c1ff535.png"; + hash = "sha256-aLHz8jSAFocrn+Pb4vRq0wtkYFJpBpZRevd+VoZC/PQ="; + }; + + fastfetch-config = pkgs.writeText "fastfetch-config.json" ( + builtins.toJSON { + "$schema" = "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json"; + modules = [ + "title" + "separator" + { + type = "os"; + keyWidth = 9; + } + { + type = "kernel"; + keyWidth = 9; + } + { + type = "uptime"; + keyWidth = 9; + } + { + type = "shell"; + keyWidth = 9; + } + "break" + { + type = "cpu"; + keyWidth = 11; + } + { + type = "memory"; + keyWidth = 11; + } + { + type = "swap"; + keyWidth = 11; + } + { + type = "disk"; + folders = "/"; + keyWidth = 11; + } + { + type = "command"; + key = "Systemd"; + keyWidth = 11; + text = "echo \"$(systemctl list-units --state=failed --no-legend | wc -l) failed units, $(systemctl list-jobs --no-legend | wc -l) queued jobs\""; + } + "break" + { + type = "command"; + key = "Public IP"; + keyWidth = 15; + text = "curl -s -4 ifconfig.me 2>/dev/null || echo 'N/A'"; + } + { + type = "command"; + key = "Tailscale IP"; + keyWidth = 15; + text = "tailscale ip -4 2>/dev/null || echo 'N/A'"; + } + { + type = "command"; + key = "Local IP"; + keyWidth = 15; + text = "ip -4 addr show scope global | grep inet | head -n1 | awk '{print $2}' | cut -d/ -f1"; + } + ]; + } + ); +in +pkgs.writeShellScriptBin "fastfetch" ''exec ${lib.getExe pkgs.fastfetch} --config ${fastfetch-config} --logo-type kitty --logo ${fastfetch-logo} --logo-padding-right 1 --logo-width 36 "$@" ''