nixos-config/modules/status-on-console.nix

40 lines
914 B
Nix
Raw Normal View History

2020-12-29 21:21:22 +00:00
{ config, pkgs, lib, ... }:
2020-10-25 08:28:55 +00:00
let
2020-12-29 21:21:22 +00:00
cfg = config.sconfig.status-on-console;
2020-10-25 08:28:55 +00:00
ncfg = pkgs.writeText "neofetch.conf" ''
print_info() {
info title
info underline
info "OS" distro
info "Host" model
info "Kernel" kernel
info "Uptime" uptime
info "CPU" cpu
info "Memory" memory
info "Disk" disk
info "Local IP" local_ip
info cols
}
'';
nscript = pkgs.writeShellScript "neofetch-wrapped" ''
2020-10-26 02:06:13 +00:00
export PATH="$PATH:/run/current-system/sw/bin"
2020-10-25 08:28:55 +00:00
(
${pkgs.neofetch}/bin/neofetch --config "${ncfg}"
echo '\l'
) >/run/issue
'';
in
{
2020-12-29 21:21:22 +00:00
options.sconfig.status-on-console = lib.mkEnableOption "Display Neofetch on system console";
config = lib.mkIf cfg {
environment.etc.issue.source = pkgs.lib.mkForce "/run/issue";
systemd.services."getty@".serviceConfig.ExecStartPre = "-${nscript}";
};
2020-10-25 08:28:55 +00:00
}