Set up nice tmux pairing config

- User foxsoft has SSH authorized keys
- When foxsoft logs on, either attaches to running tmux session or quits
This commit is contained in:
Trevor Vallender 2023-03-10 08:22:59 +00:00
parent d58ac6109f
commit 03c41c55e9
9 changed files with 68 additions and 12 deletions

View File

@ -22,6 +22,7 @@
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
users.tsv = import users/tsv/home.nix; users.tsv = import users/tsv/home.nix;
users.foxsoft = import users/foxsoft/home.nix;
}; };
} }
]; ];

View File

@ -22,6 +22,7 @@ in
networking.hostName = "ritchie"; networking.hostName = "ritchie";
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
i18n.defaultLocale = "en_GB.UTF-8";
time.timeZone = "Europe/London"; time.timeZone = "Europe/London";
# Enable sound. # Enable sound.
@ -33,14 +34,30 @@ in
pulse.enable = true; pulse.enable = true;
}; };
users.users.tsv = { users.groups.tmux.gid = 1000; # Used for tmux pairing
isNormalUser = true; systemd.tmpfiles.rules = [
extraGroups = [ "d /var/tmux_share 770 tsv tmux"
"wheel" ];
"docker"
]; users.users.tsv = {
initialPassword = "password"; isNormalUser = true;
}; extraGroups = [
"wheel"
"docker"
"tmux"
];
initialPassword = "password";
};
users.users.foxsoft = {
isNormalUser = true;
extraGroups = [
"tmux"
];
openssh.authorizedKeys.keyFiles = [
../users/foxsoft/authorized_keys
];
};
nix.settings.trusted-users = [ "root" "tsv" ]; nix.settings.trusted-users = [ "root" "tsv" ];
@ -80,7 +97,10 @@ in
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
services.openssh.enable = true; services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
};
system.stateVersion = "22.11"; # Don't change this system.stateVersion = "22.11"; # Don't change this
} }

View File

@ -0,0 +1,5 @@
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7Lsg564s9xAo+R3ompSmZCCvRDmfqRwH90xtj+4H3F72GSlcjqIWxZa3GtDinW3WAfjOZK99Ayxzyy3535Nkw5qubSt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HL9eHhTzG7VRW+CXaX67Xc6tg8I+kqF6722TEtFZ74wXBmMsn+JCn6CDtxSUtK1of8xTAO7Bl4Uq/hQ8KsdeO8J4XfRaFjiSLqiU+WcyibLkFDnW+g8sR0shOJi5Kl3ES3xgvdrxLcODKzDBHKm+jiIzVJICqPbXrzOtoXWd4xD79rGeYVrx72J8HiY6zokgUYpkVFgwzxe6OVRCQ0dfPsRtj/Mr2KAyDkRsdyeR5QhDDePoNBw5y3IbN/MB4lwOYO3mMqg589f4cUTxOQy+i7sRHVVdzdf22LdP0Kc/d9iH8lkpt7V7sn8Di3AZ/Y+NEBMw== trevor@foxsoft.co.uk

View File

@ -0,0 +1,10 @@
SOCKET_PATH="/var/tmux_share/shared"
# Connect to tmux if a session exists
tmux -S $SOCKET_PATH attach -t shared
# If a session didn't exist, delete the socket we created
[ $? -ne 0 ] && rm -f $SOCKET_PATH
# Exit, either when exiting tmux or after failing to connect
exit

4
users/foxsoft/bashrc Normal file
View File

@ -0,0 +1,4 @@
if [ -f ~/.bash_profile ]; then
source ~/.bash_profile
fi

14
users/foxsoft/home.nix Normal file
View File

@ -0,0 +1,14 @@
{ config, pkgs, ... }:
{
home.username = "foxsoft";
home.homeDirectory = "/home/foxsoft";
home.stateVersion = "22.11";
programs.home-manager.enable = true;
home.file.".bash_profile".source = ./bash_profile;
home.file.".bashrc".source = ./bashrc;
}

View File

@ -1,5 +1,3 @@
source ~/.nix-profile/etc/profile.d/hm-session-vars.sh
PAGER="less -r" PAGER="less -r"
EDITOR="nvim" EDITOR="nvim"
VISUAL="nvim" VISUAL="nvim"
@ -25,6 +23,7 @@ alias checkport="sudo netstat -tnlp | grep"
alias dockerpurge="docker system prune --all --force --volumes" alias dockerpurge="docker system prune --all --force --volumes"
alias dockerkill="docker stop `docker ps -a -q`" alias dockerkill="docker stop `docker ps -a -q`"
alias vi="nvim" alias vi="nvim"
alias tp="$HOME/bin/tmux_pair.bash"
# Prompt setup # Prompt setup
GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWDIRTYSTATE=1
@ -45,4 +44,3 @@ PS1+=' $(__git_ps1 [$YELLOW%s$CLEAR]) \n'
PS1+="ॐ \[$BOLD\]" PS1+="ॐ \[$BOLD\]"
trap 'printf "\033[0m" >&2' DEBUG trap 'printf "\033[0m" >&2' DEBUG

3
users/tsv/bashrc Normal file
View File

@ -0,0 +1,3 @@
if [ -f ~/.bash_profile ]; then
source ~/.bash_profile
fi

View File

@ -79,6 +79,7 @@
}; };
home.file.".bash_profile".source = ./bash_profile; home.file.".bash_profile".source = ./bash_profile;
home.file.".bashrc".source = ./bashrc;
home.file.".tmux.conf".source = ./tmux.conf; home.file.".tmux.conf".source = ./tmux.conf;
xdg.configFile."git/config".source = ./git/config; xdg.configFile."git/config".source = ./git/config;
xdg.configFile."git/config_foxsoft".source = ./git/config_foxsoft; xdg.configFile."git/config_foxsoft".source = ./git/config_foxsoft;