Configure host identity in Nix
This commit is contained in:
30
dotfiles/lib/functions/multiplexer_host_label
Executable file
30
dotfiles/lib/functions/multiplexer_host_label
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
multiplexer_host_label() {
|
||||
tmux_format=0
|
||||
if [ "$1" = "--tmux" ]; then
|
||||
tmux_format=1
|
||||
shift
|
||||
fi
|
||||
|
||||
host=$(hostname -s 2>/dev/null || hostname 2>/dev/null || printf unknown)
|
||||
host=${host%%.*}
|
||||
|
||||
identity_file=${MULTIPLEXER_HOST_IDENTITY_FILE:-/etc/multiplexer-host-identity}
|
||||
if [ -r "$identity_file" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$identity_file"
|
||||
fi
|
||||
|
||||
icon=${MULTIPLEXER_HOST_ICON:-🖥️}
|
||||
tmux_bg=${MULTIPLEXER_HOST_TMUX_BG:-#222222}
|
||||
tmux_fg=${MULTIPLEXER_HOST_TMUX_FG:-#ffffff}
|
||||
|
||||
if [ "$tmux_format" -eq 1 ]; then
|
||||
printf '#[fg=%s,bg=%s,bold]%s %s#[default]' "$tmux_fg" "$tmux_bg" "$icon" "$host"
|
||||
else
|
||||
printf '%s %s' "$icon" "$host"
|
||||
fi
|
||||
}
|
||||
|
||||
multiplexer_host_label "$@"
|
||||
@@ -2,7 +2,9 @@
|
||||
# Prefix + C starts a new session without prompting for a name.
|
||||
bind-key C new-session -c '#{pane_current_path}' 'codex --dangerously-bypass-approvals-and-sandbox'
|
||||
|
||||
set -g status-right '#($HOME/dotfiles/dotfiles/lib/functions/multiplexer_host_label 2>/dev/null || multiplexer_host_label 2>/dev/null || hostname -s) #{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,}"#{=21:pane_title}" %H:%M %d-%b-%y'
|
||||
source-file -q /etc/tmux-host-style.conf
|
||||
|
||||
set -g status-right '#($HOME/dotfiles/dotfiles/lib/functions/multiplexer_host_label --tmux 2>/dev/null || multiplexer_host_label --tmux 2>/dev/null || hostname -s) #{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,}"#{=21:pane_title}" %H:%M %d-%b-%y'
|
||||
set -g status-right-length 150
|
||||
set -g set-titles on
|
||||
set -g set-titles-string '#{?#{==:#{session_name},#{window_name}},#{session_name},#{session_name}:#{window_name}}#{?pane_title, - #{pane_title},}'
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
if-shell 'test -z "$POWERLINE_COMMAND"' 'if-shell "which powerline-client" "set-environment -g POWERLINE_COMMAND powerline-client" "set-environment -g POWERLINE_COMMAND powerline"'
|
||||
source-file -q /etc/tmux-host-style.conf
|
||||
set -g status on
|
||||
set -g status-utf8 on
|
||||
set -g status-interval 2
|
||||
set -g status-justify left
|
||||
set -g status-left-length 150
|
||||
set -g status-right-length 150
|
||||
set -g status-right '#(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)'
|
||||
set -g status-right '#($HOME/dotfiles/dotfiles/lib/functions/multiplexer_host_label --tmux 2>/dev/null || multiplexer_host_label --tmux 2>/dev/null || hostname -s) #(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)'
|
||||
set -g window-status-format "#[fg=white] #[fg=white,bg=black]#I #[fg=white] #[default]#W "
|
||||
set -g window-status-current-format "#[fg=black,bg=blue]#[fg=white,bg=blue] #I #[fg=white,bold]#W #[fg=blue,bg=black,nobold]"
|
||||
set-window-option -g window-status-fg white
|
||||
|
||||
@@ -71,6 +71,10 @@
|
||||
swapDevices = [];
|
||||
|
||||
networking.hostName = "adell";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "💻";
|
||||
tmux.background = "#7c3aed";
|
||||
};
|
||||
|
||||
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
myModules.wsl.enable = true;
|
||||
|
||||
networking.hostName = "bencbox";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "📦";
|
||||
tmux.background = "#b45309";
|
||||
};
|
||||
|
||||
wsl.defaultUser = "ben";
|
||||
system.stateVersion = "22.05";
|
||||
|
||||
@@ -162,6 +162,10 @@ in {
|
||||
];
|
||||
|
||||
networking.hostName = "biskcomp";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "🧮";
|
||||
tmux.background = "#0f766e";
|
||||
};
|
||||
system.stateVersion = "23.11";
|
||||
|
||||
home-manager.sharedModules = [
|
||||
|
||||
@@ -55,6 +55,10 @@
|
||||
];
|
||||
|
||||
networking.hostName = "david-blade";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "🗡️";
|
||||
tmux.background = "#be123c";
|
||||
};
|
||||
|
||||
home-manager.sharedModules = [
|
||||
{
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
myModules.wsl.enable = true;
|
||||
|
||||
networking.hostName = "dean-zephyrus";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "🌬️";
|
||||
tmux.background = "#0284c7";
|
||||
};
|
||||
|
||||
wsl.defaultUser = "dean";
|
||||
system.stateVersion = "22.05";
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
myModules.wsl.enable = true;
|
||||
|
||||
networking.hostName = "jay-lenovo-wsl";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "💼";
|
||||
tmux.background = "#15803d";
|
||||
};
|
||||
|
||||
wsl.defaultUser = "kat";
|
||||
system.stateVersion = "22.05";
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
};
|
||||
|
||||
networking.hostName = "jay-lenovo";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "💼";
|
||||
tmux.background = "#16a34a";
|
||||
};
|
||||
|
||||
services.power-profiles-daemon.enable = false;
|
||||
services.tlp.enable = true;
|
||||
|
||||
@@ -120,6 +120,11 @@
|
||||
];
|
||||
|
||||
networking.hostName = "jimi-hendnix";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "🎸";
|
||||
tmux.background = "#ca8a04";
|
||||
tmux.foreground = "#111111";
|
||||
};
|
||||
|
||||
system.stateVersion = "23.05";
|
||||
}
|
||||
|
||||
@@ -198,6 +198,10 @@
|
||||
swapDevices = [];
|
||||
|
||||
networking.hostName = "justin-bieber-creek";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "🎤";
|
||||
tmux.background = "#c026d3";
|
||||
};
|
||||
|
||||
networking.useDHCP = false;
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
services.k3s.enable = lib.mkForce false;
|
||||
|
||||
networking.hostName = "nixquick";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "🐩";
|
||||
tmux.background = "#db2777";
|
||||
};
|
||||
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"];
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
];
|
||||
|
||||
networking.hostName = "railbird-sf";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "🐦";
|
||||
tmux.background = "#0891b2";
|
||||
};
|
||||
|
||||
# Allow nginx to serve content synced into /var/lib/syncthing/* (owned by syncthing:syncthing, 2770 perms).
|
||||
users.users.nginx.extraGroups = ["syncthing"];
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
boot.loader.systemd-boot.configurationLimit = 5;
|
||||
|
||||
networking.hostName = "ryzen-shine";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "☀️";
|
||||
tmux.background = "#ea580c";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
perf
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
myModules.wsl.enable = true;
|
||||
|
||||
networking.hostName = "ryzen-shine-wsl";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "☀️";
|
||||
tmux.background = "#f97316";
|
||||
};
|
||||
|
||||
wsl.defaultUser = "imalison";
|
||||
system.stateVersion = "22.05";
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
};
|
||||
|
||||
networking.hostName = "ryzen-shine";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "☀️";
|
||||
tmux.background = "#ea580c";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
perf
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
myModules.wsl.enable = true;
|
||||
|
||||
networking.hostName = "strixi-minaj-wsl";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "👩🏿";
|
||||
tmux.background = "#4338ca";
|
||||
};
|
||||
|
||||
wsl.defaultUser = "imalison";
|
||||
system.stateVersion = "23.11"; # Did you read the comment?
|
||||
|
||||
@@ -103,6 +103,10 @@
|
||||
];
|
||||
|
||||
networking.hostName = "strixi-minaj";
|
||||
myModules.hostIdentity = {
|
||||
emoticon = "👩🏿";
|
||||
tmux.background = "#4f46e5";
|
||||
};
|
||||
|
||||
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault true;
|
||||
|
||||
@@ -1,8 +1,50 @@
|
||||
{lib, ...}: {
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
hostIdentity = config.myModules.hostIdentity;
|
||||
in {
|
||||
options = {
|
||||
myModules.hostIdentity = {
|
||||
emoticon = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "🖥️";
|
||||
description = "Short visual marker used when displaying this host in multiplexer status bars.";
|
||||
};
|
||||
|
||||
tmux = {
|
||||
background = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "#222222";
|
||||
description = "tmux status bar background color for this host.";
|
||||
};
|
||||
|
||||
foreground = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "#ffffff";
|
||||
description = "tmux status bar foreground color for this host.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
myModules.xmonad.picom.vSync.enable = lib.mkOption {
|
||||
default = true;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
environment.etc."multiplexer-host-identity".text = ''
|
||||
MULTIPLEXER_HOST_ICON=${lib.escapeShellArg hostIdentity.emoticon}
|
||||
MULTIPLEXER_HOST_TMUX_BG=${lib.escapeShellArg hostIdentity.tmux.background}
|
||||
MULTIPLEXER_HOST_TMUX_FG=${lib.escapeShellArg hostIdentity.tmux.foreground}
|
||||
'';
|
||||
|
||||
environment.etc."tmux-host-style.conf".text = ''
|
||||
set -g status-style "fg=${hostIdentity.tmux.foreground},bg=${hostIdentity.tmux.background}"
|
||||
set -g status-left-style "fg=${hostIdentity.tmux.foreground},bg=${hostIdentity.tmux.background}"
|
||||
set -g status-right-style "fg=${hostIdentity.tmux.foreground},bg=${hostIdentity.tmux.background}"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user