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
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
This commit is contained in:
parent
62954eb986
commit
6c095843ba
8
.bashrc
8
.bashrc
@ -67,11 +67,6 @@ if [ -t 1 ]; then
|
|||||||
alias ls='l'
|
alias ls='l'
|
||||||
fi
|
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
|
# PATH Manipulation
|
||||||
export DOTFILES_PATH=$HOME/.dotfiles
|
export DOTFILES_PATH=$HOME/.dotfiles
|
||||||
export PATH=$PATH:$HOME/.local/bin
|
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"
|
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source agent-bridge script for 1password
|
|
||||||
source $DOTFILES_PATH/bin/1password-agent-bridge.sh
|
|
||||||
|
|
||||||
# zoxide if available
|
# zoxide if available
|
||||||
if command -v zoxide &> /dev/null; then
|
if command -v zoxide &> /dev/null; then
|
||||||
eval "$(zoxide init bash)"
|
eval "$(zoxide init bash)"
|
||||||
|
@ -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 ]"
|
|
@ -10,18 +10,9 @@ import glob
|
|||||||
sys.path.append(os.path.join(os.path.expanduser("~/.dotfiles"), "bin"))
|
sys.path.append(os.path.join(os.path.expanduser("~/.dotfiles"), "bin"))
|
||||||
from helpers.functions import printfe, run_command
|
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():
|
def get_password():
|
||||||
"""Get password from 1Password"""
|
"""Get password from 1Password"""
|
||||||
# Choose the appropriate op command based on WSL status
|
op_cmd = "op"
|
||||||
op_cmd = "op.exe" if is_wsl() else "op"
|
|
||||||
|
|
||||||
# Try to get the password
|
# Try to get the password
|
||||||
success, output = run_command([op_cmd, "item", "get", "Dotfiles Secrets", "--fields", "password"])
|
success, output = run_command([op_cmd, "item", "get", "Dotfiles Secrets", "--fields", "password"])
|
||||||
|
@ -95,3 +95,43 @@ def run_command(command, shell=False):
|
|||||||
return True, result.stdout.strip()
|
return True, result.stdout.strip()
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return False, e.stderr.strip()
|
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
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
- trash-cli
|
- trash-cli
|
||||||
- curl
|
- curl
|
||||||
- wget
|
- wget
|
||||||
|
- python3
|
||||||
|
- python3-pip
|
||||||
|
- python3-venv
|
||||||
state: present
|
state: present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user