···
options.atelier.shell.enable = lib.mkEnableOption "Custom shell config";
config = lib.mkIf config.atelier.shell.enable {
···
-
# Configuration variables - set these to your defaults
-
local default_plc_id="did:plc:krxbvxvis5skq7jj6eot23ul"
-
local default_github_username="taciturnaxolotl"
-
local default_knot_host="knot.dunkirk.sh"
-
local extracted_github_username=""
-
# Check if current directory is a git repository
-
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
-
echo "Not a git repository"
-
# Get the repository name from the current directory
-
local repo_name=$(basename "$(git rev-parse --show-toplevel)")
-
# Check if origin remote exists and points to knot
-
local origin_url=$(git remote get-url origin 2>/dev/null)
-
local origin_knot=false
-
if [[ -n "$origin_url" ]]; then
-
# Try to extract GitHub username if origin is a GitHub URL
-
if [[ "$origin_url" == *"github.com"* ]]; then
-
extracted_github_username=$(echo "$origin_url" | sed -E 's/.*github\.com[:/]([^/]+)\/.*$/\1/')
-
# Override the default username with the extracted one
-
default_github_username=$extracted_github_username
-
if [[ "$origin_url" == *"$default_knot_host"* || "$origin_url" == *"knot.dunkirk.sh"* ]]; then
-
echo "✅ Origin remote exists and points to knot"
-
echo "⚠️ Origin remote exists but doesn't point to knot"
-
echo "⚠️ Origin remote doesn't exist"
-
# Check if github remote exists
-
local github_exists=false
-
if git remote get-url github &>/dev/null; then
-
echo "✅ GitHub remote exists"
-
echo "⚠️ GitHub remote doesn't exist"
-
# Fix remotes if needed
-
if [[ "$origin_knot" = false || "$github_exists" = false ]]; then
-
# Prompt for PLC identifier if needed
-
local should_fix_origin=false
-
if [[ "$origin_knot" = false ]]; then
-
if [[ -n "$origin_url" ]]; then
-
echo -n "Migrate origin from $origin_url to knot.dunkirk.sh? [Y/n]: "
-
if [[ -z "$fix_input" || "$fix_input" =~ ^[Yy]$ ]]; then
-
if [[ "$should_fix_origin" = true ]]; then
-
echo -n "Enter your PLC identifier [default: $default_plc_id]: "
-
plc_id=''${plc_input:-$default_plc_id}
-
# Prompt for GitHub username with default from origin if available
-
local github_username=""
-
if [[ "$github_exists" = false ]]; then
-
echo -n "Enter your GitHub username [default: $default_github_username]: "
-
github_username=''${github_input:-$default_github_username}
-
# Set up origin remote if needed
-
if [[ "$should_fix_origin" = true && -n "$plc_id" ]]; then
-
if git remote get-url origin &>/dev/null; then
-
git remote remove origin
-
git remote add origin "git@$default_knot_host:''${plc_id}/''${repo_name}"
-
echo "✅ Set up origin remote: git@$default_knot_host:''${plc_id}/''${repo_name}"
-
# Set up GitHub remote if needed
-
if [[ "$github_exists" = false && -n "$github_username" ]]; then
-
git remote add github "git@github.com:''${github_username}/''${repo_name}.git"
-
echo "✅ Set up GitHub remote: git@github.com:''${github_username}/''${repo_name}.git"
-
echo "Remotes are correctly configured"
-
# Check default push remote
-
local current_remote=$(git config --get branch.main.remote 2>/dev/null)
-
if [[ -z "$current_remote" ]]; then
-
echo "⚠️ No default push remote set for main branch"
-
echo -n "Set origin (knot) as default push remote? [Y/n]: "
-
if [[ -z "$remote_input" || "$remote_input" =~ ^[Yy]$ ]]; then
-
git config branch.main.remote origin
-
echo "✅ Set origin as default push remote for main branch"
-
elif [[ "$current_remote" != "origin" ]]; then
-
echo "ℹ️ Current default push remote: $current_remote"
-
echo -n "Change to origin (knot)? [y/N]: "
-
if [[ "$remote_input" =~ ^[Yy]$ ]]; then
-
git config branch.main.remote origin
-
echo "✅ Changed default push remote to origin"
-
echo "✅ Default push remote is origin"
# Post AtProto status updates
···
home.packages = with pkgs; [
pkgs.unstable.wakatime-cli
inputs.terminal-wakatime.packages.${pkgs.system}.default