···
9
+
tangled-setup = pkgs.writeShellScriptBin "tangled-setup" ''
11
+
default_plc_id="did:plc:krxbvxvis5skq7jj6eot23ul"
12
+
default_github_username="taciturnaxolotl"
13
+
default_knot_host="knot.dunkirk.sh"
15
+
# Verify git repository
16
+
if ! ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null; then
17
+
${pkgs.gum}/bin/gum style --foreground 196 "Not a git repository"
21
+
repo_name=$(basename "$(${pkgs.git}/bin/git rev-parse --show-toplevel)")
22
+
${pkgs.gum}/bin/gum style --bold --foreground 212 "Configuring tangled remotes for: $repo_name"
25
+
# Check current remotes
26
+
origin_url=$(${pkgs.git}/bin/git remote get-url origin 2>/dev/null)
27
+
github_url=$(${pkgs.git}/bin/git remote get-url github 2>/dev/null)
28
+
origin_is_knot=false
29
+
github_username="$default_github_username"
31
+
# Extract GitHub username from existing origin if it's GitHub
32
+
if [[ "$origin_url" == *"github.com"* ]]; then
33
+
github_username=$(echo "$origin_url" | ${pkgs.gnused}/bin/sed -E 's/.*github\.com[:/]([^/]+)\/.*$/\1/')
36
+
# Check if origin points to knot
37
+
if [[ "$origin_url" == *"$default_knot_host"* ]]; then
39
+
${pkgs.gum}/bin/gum style --foreground 35 "✓ Origin → knot ($origin_url)"
40
+
elif [[ -n "$origin_url" ]]; then
41
+
${pkgs.gum}/bin/gum style --foreground 214 "! Origin → $origin_url (not knot)"
43
+
${pkgs.gum}/bin/gum style --foreground 214 "! Origin not configured"
46
+
# Check github remote
47
+
if [[ -n "$github_url" ]]; then
48
+
${pkgs.gum}/bin/gum style --foreground 35 "✓ GitHub → $github_url"
50
+
${pkgs.gum}/bin/gum style --foreground 214 "! GitHub remote not configured"
55
+
# Configure origin remote if needed
56
+
if [[ "$origin_is_knot" = false ]]; then
58
+
if [[ -n "$origin_url" ]]; then
59
+
${pkgs.gum}/bin/gum confirm "Migrate origin from $origin_url to knot?" || should_migrate=false
62
+
if [[ "$should_migrate" = true ]]; then
63
+
plc_id=$(${pkgs.gum}/bin/gum input --placeholder "$default_plc_id" --prompt "PLC ID: " --value "$default_plc_id")
64
+
plc_id=''${plc_id:-$default_plc_id}
66
+
if ${pkgs.git}/bin/git remote get-url origin &>/dev/null; then
67
+
${pkgs.git}/bin/git remote remove origin
69
+
${pkgs.git}/bin/git remote add origin "git@$default_knot_host:''${plc_id}/''${repo_name}"
70
+
${pkgs.gum}/bin/gum style --foreground 35 "✓ Configured origin → git@$default_knot_host:''${plc_id}/''${repo_name}"
74
+
# Configure github remote if needed
75
+
if [[ -z "$github_url" ]]; then
76
+
username=$(${pkgs.gum}/bin/gum input --placeholder "$github_username" --prompt "GitHub username: " --value "$github_username")
77
+
username=''${username:-$github_username}
79
+
${pkgs.git}/bin/git remote add github "git@github.com:''${username}/''${repo_name}.git"
80
+
${pkgs.gum}/bin/gum style --foreground 35 "✓ Configured github → git@github.com:''${username}/''${repo_name}.git"
85
+
# Configure default push remote
86
+
current_remote=$(${pkgs.git}/bin/git config --get branch.main.remote 2>/dev/null)
87
+
if [[ -z "$current_remote" ]]; then
88
+
if ${pkgs.gum}/bin/gum confirm "Set origin (knot) as default push remote?"; then
89
+
${pkgs.git}/bin/git config branch.main.remote origin
90
+
${pkgs.gum}/bin/gum style --foreground 35 "✓ Default push remote → origin"
92
+
elif [[ "$current_remote" != "origin" ]]; then
93
+
${pkgs.gum}/bin/gum style --foreground 117 "Current default: $current_remote"
94
+
if ${pkgs.gum}/bin/gum confirm "Change default push remote to origin (knot)?"; then
95
+
${pkgs.git}/bin/git config branch.main.remote origin
96
+
${pkgs.gum}/bin/gum style --foreground 35 "✓ Default push remote → origin"
99
+
${pkgs.gum}/bin/gum style --foreground 35 "✓ Default push remote is origin"
options.atelier.shell.enable = lib.mkEnableOption "Custom shell config";
config = lib.mkIf config.atelier.shell.enable {
···
169
-
# Configuration variables - set these to your defaults
170
-
local default_plc_id="did:plc:krxbvxvis5skq7jj6eot23ul"
171
-
local default_github_username="taciturnaxolotl"
172
-
local default_knot_host="knot.dunkirk.sh"
173
-
local extracted_github_username=""
175
-
# Check if current directory is a git repository
176
-
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
177
-
echo "Not a git repository"
181
-
# Get the repository name from the current directory
182
-
local repo_name=$(basename "$(git rev-parse --show-toplevel)")
184
-
# Check if origin remote exists and points to knot
185
-
local origin_url=$(git remote get-url origin 2>/dev/null)
186
-
local origin_knot=false
188
-
if [[ -n "$origin_url" ]]; then
189
-
# Try to extract GitHub username if origin is a GitHub URL
190
-
if [[ "$origin_url" == *"github.com"* ]]; then
191
-
extracted_github_username=$(echo "$origin_url" | sed -E 's/.*github\.com[:/]([^/]+)\/.*$/\1/')
192
-
# Override the default username with the extracted one
193
-
default_github_username=$extracted_github_username
196
-
if [[ "$origin_url" == *"$default_knot_host"* || "$origin_url" == *"knot.dunkirk.sh"* ]]; then
198
-
echo "✅ Origin remote exists and points to knot"
200
-
echo "⚠️ Origin remote exists but doesn't point to knot"
203
-
echo "⚠️ Origin remote doesn't exist"
206
-
# Check if github remote exists
207
-
local github_exists=false
208
-
if git remote get-url github &>/dev/null; then
210
-
echo "✅ GitHub remote exists"
212
-
echo "⚠️ GitHub remote doesn't exist"
215
-
# Fix remotes if needed
216
-
if [[ "$origin_knot" = false || "$github_exists" = false ]]; then
217
-
# Prompt for PLC identifier if needed
219
-
local should_fix_origin=false
221
-
if [[ "$origin_knot" = false ]]; then
222
-
if [[ -n "$origin_url" ]]; then
223
-
echo -n "Migrate origin from $origin_url to knot.dunkirk.sh? [Y/n]: "
225
-
if [[ -z "$fix_input" || "$fix_input" =~ ^[Yy]$ ]]; then
226
-
should_fix_origin=true
229
-
should_fix_origin=true
232
-
if [[ "$should_fix_origin" = true ]]; then
233
-
echo -n "Enter your PLC identifier [default: $default_plc_id]: "
235
-
plc_id=''${plc_input:-$default_plc_id}
239
-
# Prompt for GitHub username with default from origin if available
240
-
local github_username=""
241
-
if [[ "$github_exists" = false ]]; then
242
-
echo -n "Enter your GitHub username [default: $default_github_username]: "
244
-
github_username=''${github_input:-$default_github_username}
247
-
# Set up origin remote if needed
248
-
if [[ "$should_fix_origin" = true && -n "$plc_id" ]]; then
249
-
if git remote get-url origin &>/dev/null; then
250
-
git remote remove origin
252
-
git remote add origin "git@$default_knot_host:''${plc_id}/''${repo_name}"
253
-
echo "✅ Set up origin remote: git@$default_knot_host:''${plc_id}/''${repo_name}"
256
-
# Set up GitHub remote if needed
257
-
if [[ "$github_exists" = false && -n "$github_username" ]]; then
258
-
git remote add github "git@github.com:''${github_username}/''${repo_name}.git"
259
-
echo "✅ Set up GitHub remote: git@github.com:''${github_username}/''${repo_name}.git"
262
-
echo "Remotes are correctly configured"
265
-
# Check default push remote
266
-
local current_remote=$(git config --get branch.main.remote 2>/dev/null)
267
-
if [[ -z "$current_remote" ]]; then
268
-
echo "⚠️ No default push remote set for main branch"
269
-
echo -n "Set origin (knot) as default push remote? [Y/n]: "
271
-
if [[ -z "$remote_input" || "$remote_input" =~ ^[Yy]$ ]]; then
272
-
git config branch.main.remote origin
273
-
echo "✅ Set origin as default push remote for main branch"
275
-
elif [[ "$current_remote" != "origin" ]]; then
276
-
echo "ℹ️ Current default push remote: $current_remote"
277
-
echo -n "Change to origin (knot)? [y/N]: "
279
-
if [[ "$remote_input" =~ ^[Yy]$ ]]; then
280
-
git config branch.main.remote origin
281
-
echo "✅ Changed default push remote to origin"
284
-
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