Compare commits

..

2 Commits

10 changed files with 201 additions and 8 deletions
+97 -8
View File
@@ -1,6 +1,9 @@
STOW_TARGET := $(HOME)
HOME_TARGET ?= $(HOME)
SYSTEM_DIRS := etc usr var opt boot
PACKAGES := $(patsubst %/,%,$(wildcard */))
.PHONY: check-stow pull-updates unlink link
.PHONY: check-stow
check-stow:
@command -v stow >/dev/null 2>&1 && { \
echo "✅ stow already installed"; \
@@ -35,17 +38,103 @@ check-stow:
;; \
esac
.PHONY: pull-updates
pull-updates:
@echo "Pulling all recent updates"
@git pull origin main
@git submodule update --recursive --remote
.PHONY: link
unlink:
@echo "Unlinking dotfiles to machine"
@for pkg in $(PACKAGES); do \
echo ">>> Unstowing package: $$pkg"; \
for subdir in "$$pkg"/* "$$pkg"/.[!.]*; do \
[ -d "$$subdir" ] || continue; \
sub="$${subdir##*/}"; \
is_sys=0; \
for sys in $(SYSTEM_DIRS); do \
[ "$$sub" = "$$sys" ] && is_sys=1 && break; \
done; \
if [ "$$is_sys" -eq 1 ]; then \
echo " [SYSTEM] Unstowing $$pkg/$$sub from $$sub"; \
sudo stow -D -d "$$pkg" -t "/$$sub" "$$sub"; \
else \
echo " [USER] Unstowing $$pkg/$$sub from $(HOME_TARGET)/$$sub"; \
stow -D -d "$$pkg" -t "$(HOME_TARGET)/$$sub" "$$sub"; \
fi; \
done; \
done
link: check-stow
@echo "Linking dotfiles to machine"
@for pkg in *; do \
[ -d "$$pkg" ] || continue; \
echo "📦 stowing $$pkg"; \
stow -R "$$pkg" -t "$(STOW_TARGET)" --adopt; \
@for pkg in $(PACKAGES); do \
echo ">>> Processing package: $$pkg"; \
for subdir in "$$pkg"/* "$$pkg"/.[!.]*; do \
[ -d "$$subdir" ] || continue; \
sub="$${subdir##*/}"; \
is_sys=0; \
for sys in $(SYSTEM_DIRS); do \
[ "$$sub" == "$$sys" ] && is_sys=1 && break; \
done; \
if [ "$$is_sys" -eq 1 ]; then \
echo " [System] Stowing $$pkg/$$sub to $$sub"; \
sudo stow -d "$$pkg" -t "/$$sub" "$$sub"; \
else \
echo " [USER] Stowing $$pkg/$$sub to $(HOME_TARGET)/$$sub"; \
stow -d "$$pkg" -t "$(HOME_TARGET)/$$sub" "$$sub"; \
fi; \
done; \
done
# # Define variables
# HOME_TARGET ?= $(HOME)
# # Space-separated list of directories that should go to the system root
# SYSTEM_DIRS := etc usr var opt boot
#
# # Find all top-level directories in your dotfiles repo (e.g., 'systemd', 'nvim')
# PACKAGES := $(patsubst %/,%,$(wildcard */))
#
# .PHONY: all stow unstow
#
# all: stow
#
# stow:
# @for pkg in $(PACKAGES); do \
# echo ">>> Processing package: $$pkg"; \
# for subdir in "$$pkg"/* "$$pkg"/.[!.]*; do \
# [ -d "$$subdir" ] || continue; \
# sub="$${subdir##*/}"; \
# is_sys=0; \
# for sys in $(SYSTEM_DIRS); do \
# [ "$$sub" = "$$sys" ] && is_sys=1 && break; \
# done; \
# if [ "$$is_sys" -eq 1 ]; then \
# echo " [System] Stowing $$pkg/$$sub to /$$sub"; \
# sudo mkdir -p "/$$sub"; \
# sudo stow -d "$$pkg" -t "/$$sub" "$$sub"; \
# else \
# echo " [User] Stowing $$pkg/$$sub to $(HOME_TARGET)/$$sub"; \
# mkdir -p "$(HOME_TARGET)/$$sub"; \
# stow -d "$$pkg" -t "$(HOME_TARGET)/$$sub" "$$sub"; \
# fi; \
# done; \
# done
#
# unstow:
# @for pkg in $(PACKAGES); do \
# echo ">>> Unstowing package: $$pkg"; \
# for subdir in "$$pkg"/* "$$pkg"/.[!.]*; do \
# [ -d "$$subdir" ] || continue; \
# sub="$${subdir##*/}"; \
# is_sys=0; \
# for sys in $(SYSTEM_DIRS); do \
# [ "$$sub" = "$$sys" ] && is_sys=1 && break; \
# done; \
# if [ "$$is_sys" -eq 1 ]; then \
# echo " [System] Unstowing $$pkg/$$sub from /$$sub"; \
# sudo stow -D -d "$$pkg" -t "/$$sub" "$$sub"; \
# else \
# echo " [User] Unstowing $$pkg/$$sub from $(HOME_TARGET)/$$sub"; \
# stow -D -d "$$pkg" -t "$(HOME_TARGET)/$$sub" "$$sub"; \
# fi; \
# done; \
# done
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
set -xe
USERNAME=$(op read "op://Personal/Main NAS/username" 2>&1)
PASSWORD=$(op read "op://Personal/Main NAS/password" 2>&1)
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
echo "Failed to fetch credentials" >&2
exit 1
fi
CRED_DIR="$HOME/.nas"
mkdir -p "$CRED_DIR"
chmod 700 "$CRED_DIR"
cat >"$CRED_DIR/.smbcredentials" <<EOF
username=$USERNAME
password=$PASSWORD
EOF
chmod 600 "$CRED_DIR/.smbcredentials"
@@ -0,0 +1,17 @@
[Unit]
Description=Fetch NAS credentials from 1Password
After=op-cli-signin.service
[Service]
Type=oneshot
Environment="DISPLAY=:0"
Environment="WAYLAND_DISPLAY=wayland-0"
Environment="OP_BIOMETRIC_UNLOCK_ENABLED=true"
ExecStart=sudo -u sammieo -E /home/sammieo/.local/bin/fetch-nas-credentials.sh
ExecStartPost=sudo -u sammieo /usr/bin/systemctl start nas-mounts.target
RemainAfterExit=yes
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=default.target
@@ -0,0 +1,13 @@
[Unit]
Description=1Password CLI SignIn
After=graphical-session.target
[Service]
Type=oneshot
Environment="DISPLAY=:0"
Environment="WAYLAND_DISPLAY=wayland-0"
Environment="OP_BIOMETRIC_UNLOCK_ENABLED=true"
ExecStart=/bin/sh op signin
[Install]
WantedBy=default.target
@@ -0,0 +1,9 @@
[Unit]
Description=Automount NAS Docker Share
[Automount]
Where=/mnt/nas/docker
TimeoutIdleSec=600
[Install]
WantedBy=nas-mounts.target
@@ -0,0 +1,13 @@
[Unit]
Description=NAS SMB Mount (Docker)
After=network-online.target
Wants=network-online.target
[Mount]
What=//192.168.68.77/docker/
Where=/mnt/nas/docker/
Type=cifs
Options=credentials=/home/sammieo/.nas/.smbcredentials,uid=1000,gid=1000,file_mode=0755,dir_mode=0755
TimeoutSec=30
@@ -0,0 +1,9 @@
[Unit]
Description=Automount NAS Docker Share
[Automount]
Where=/mnt/nas/media
TimeoutIdleSec=600
[Install]
WantedBy=nas-mounts.target
@@ -0,0 +1,13 @@
[Unit]
Description=NAS SMB Mount (Media)
After=network-online.target
Wants=network-online.target
[Mount]
What=//192.168.68.77/Partition_1/media/
Where=/mnt/nas/media/
Type=cifs
Options=credentials=/home/sammieo/.nas/.smbcredentials,uid=1000,gid=1000,file_mode=0755,dir_mode=0755
TimeoutSec=30
@@ -0,0 +1,6 @@
[Unit]
Description=All NAS Network Mounts
StopWhenUnneeded=yes
[Install]
WantedBy=default.target
+2
View File
@@ -137,3 +137,5 @@ export HOSTALIASES=$HOME/.config/hosts
# Pip
alias pip=pip3
. "/home/sammieo/.deno/env"
export LC_ALL="en_US.UTF-8"