feat: remove WSL-specific aliases and 1Password agent bridge script; add dependency checks and installation for Python packages
Some checks failed
Nix Format Check / check-format (push) Failing after 38s

This commit is contained in:
Menno van Leeuwen 2025-03-10 15:59:28 +01:00
parent 62954eb986
commit 6c095843ba
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
5 changed files with 44 additions and 39 deletions

View File

@ -67,11 +67,6 @@ if [ -t 1 ]; then
alias ls='l'
fi
# Alias for ssh.exe and ssh-add.exe on Windows WSL (microsoft-standard-WSL2)
if [[ $(uname -a) == *"microsoft-standard-WSL2"* ]]; then
alias op='op.exe'
fi
# PATH Manipulation
export DOTFILES_PATH=$HOME/.dotfiles
export PATH=$PATH:$HOME/.local/bin
@ -118,9 +113,6 @@ if [ -f "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
fi
# Source agent-bridge script for 1password
source $DOTFILES_PATH/bin/1password-agent-bridge.sh
# zoxide if available
if command -v zoxide &> /dev/null; then
eval "$(zoxide init bash)"

View File

@ -1,21 +0,0 @@
source $DOTFILES_PATH/bin/helpers/functions.sh
export SSH_AUTH_SOCK=$HOME/.1password/agent.sock
# Check if is_wsl function returns true, don't continue if we are not on WSL
if ! is_wsl; then
return
fi
printfe "%s" "cyan" "Running in WSL, ensuring 1Password SSH-Agent relay is running..."
ALREADY_RUNNING=$(ps -auxww | grep -q "[n]piperelay.exe -ei -s //./pipe/openssh-ssh-agent"; echo $?)
if [[ $ALREADY_RUNNING != "0" ]]; then
if [[ -S $SSH_AUTH_SOCK ]]; then
rm $SSH_AUTH_SOCK
fi
(setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1
printfe "%s\n" "green" " [ Started ]"
exit 0
fi
printfe "%s\n" "green" " [ Already running ]"

View File

@ -10,18 +10,9 @@ import glob
sys.path.append(os.path.join(os.path.expanduser("~/.dotfiles"), "bin"))
from helpers.functions import printfe, run_command
def is_wsl():
"""Check if running under WSL"""
try:
with open('/proc/version', 'r') as f:
return 'microsoft' in f.read().lower()
except:
return False
def get_password():
"""Get password from 1Password"""
# Choose the appropriate op command based on WSL status
op_cmd = "op.exe" if is_wsl() else "op"
op_cmd = "op"
# Try to get the password
success, output = run_command([op_cmd, "item", "get", "Dotfiles Secrets", "--fields", "password"])

View File

@ -95,3 +95,43 @@ def run_command(command, shell=False):
return True, result.stdout.strip()
except subprocess.CalledProcessError as e:
return False, e.stderr.strip()
def ensure_dependencies():
"""Check and install required dependencies for the dotfiles system"""
required_packages = [
'pyfiglet', # For ASCII art generation
]
missing_packages = []
for package in required_packages:
try:
__import__(package)
except ImportError:
missing_packages.append(package)
if missing_packages:
printfe("yellow", f"Missing dependencies: {', '.join(missing_packages)}")
install = input("Would you like to install them now? (y/n): ").lower()
if install == 'y' or install == 'yes':
printfe("cyan", "Installing missing dependencies...")
for package in missing_packages:
printfe("blue", f"Installing {package}...")
success, output = run_command(['pip', 'install', '--user', package])
if success:
printfe("green", f"Successfully installed {package}")
# Attempt to import the newly installed package
if package == 'pyfiglet':
try:
global pyfiglet
import pyfiglet
except ImportError:
printfe("red", f"Failed to import {package} after installation")
else:
printfe("red", f"Failed to install {package}: {output}")
printfe("green", "All dependencies have been processed")
return True
else:
printfe("yellow", "Skipping dependency installation")
return False
return True

View File

@ -31,6 +31,9 @@
- trash-cli
- curl
- wget
- python3
- python3-pip
- python3-venv
state: present
become: true