Kieran's opinionated (and probably slightly dumb) nix config

feat: update ghrpc

dunkirk.sh f2b1f574 27d4c9fd

verified
+154 -1
+4
machines/atalanta/default.nix
··· 117 117 file = ../../secrets/pbnj.age; 118 118 owner = "kierank"; 119 119 }; 120 + tangled-session = { 121 + file = ../../secrets/tangled-session.age; 122 + owner = "kierank"; 123 + }; 120 124 }; 121 125 122 126 environment.variables = {
+147 -1
modules/home/system/shell.nix
··· 373 373 ${pkgs.gum}/bin/gum style --foreground 35 --bold "Done! Ghostty is ready on $target" 374 374 ''; 375 375 376 + ghrpc = pkgs.writeShellScriptBin "ghrpc" '' 377 + # Create GitHub and Tangled repos 378 + default_plc_id="did:plc:krxbvxvis5skq7jj6eot23ul" 379 + default_knot_host="knot.dunkirk.sh" 380 + default_tangled_domain="knot.dunkirk.sh" 381 + default_branch="main" 382 + 383 + # Check if we're in a git repository 384 + if ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null; then 385 + repo_name=$(basename "$(${pkgs.git}/bin/git rev-parse --show-toplevel)") 386 + ${pkgs.gum}/bin/gum style --foreground 214 "Already in a git repository: $repo_name" 387 + ${pkgs.gum}/bin/gum style --foreground 214 "This will add remotes to the existing repository." 388 + echo 389 + else 390 + # Get repository name 391 + repo_name=$(${pkgs.gum}/bin/gum input --placeholder "my-awesome-project" --prompt "Repository name: ") 392 + if [[ -z "$repo_name" ]]; then 393 + ${pkgs.gum}/bin/gum style --foreground 196 "No repository name provided" 394 + exit 1 395 + fi 396 + fi 397 + 398 + ${pkgs.gum}/bin/gum style --bold --foreground 212 "Creating repository: $repo_name" 399 + echo 400 + 401 + # Get description 402 + description=$(${pkgs.gum}/bin/gum input --placeholder "A cool project" --prompt "Description: ") 403 + description=''${description:-""} 404 + 405 + # Get visibility 406 + if ${pkgs.gum}/bin/gum confirm "Make repository public?"; then 407 + visibility="public" 408 + else 409 + visibility="private" 410 + fi 411 + 412 + # Create on Tangled 413 + if ${pkgs.gum}/bin/gum confirm "Create on Tangled?"; then 414 + ${pkgs.gum}/bin/gum style --foreground 117 "Tangled configuration:" 415 + 416 + # Check for tangled session cookie 417 + tangled_cookie="" 418 + if [[ -f "/run/agenix/tangled-session" ]]; then 419 + tangled_cookie=$(cat /run/agenix/tangled-session) 420 + fi 421 + 422 + if [[ -z "$tangled_cookie" ]]; then 423 + ${pkgs.gum}/bin/gum style --foreground 214 "⚠ No tangled session cookie found" 424 + ${pkgs.gum}/bin/gum style --foreground 214 " Please copy your appview-session-v2 cookie from tangled.org" 425 + tangled_cookie=$(${pkgs.gum}/bin/gum input --password --placeholder "appview-session-v2=..." --prompt "Cookie: ") 426 + 427 + if [[ -z "$tangled_cookie" ]]; then 428 + ${pkgs.gum}/bin/gum style --foreground 196 "No cookie provided, skipping Tangled" 429 + fi 430 + fi 431 + 432 + if [[ -n "$tangled_cookie" ]]; then 433 + tangled_domain=$(${pkgs.gum}/bin/gum input --placeholder "$default_tangled_domain" --prompt "Domain: " --value "$default_tangled_domain") 434 + tangled_domain=''${tangled_domain:-$default_tangled_domain} 435 + 436 + # URL encode the description 437 + encoded_desc=$(echo -n "$description" | ${pkgs.gnused}/bin/sed 's/ /%20/g; s/!/%21/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/'"'"'/%27/g; s/(/%28/g; s/)/%29/g; s/\*/%2A/g; s/+/%2B/g; s/,/%2C/g; s/\//%2F/g; s/:/%3A/g; s/;/%3B/g; s/=/%3D/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\]/%5D/g') 438 + 439 + ${pkgs.gum}/bin/gum spin --spinner dot --title "Creating repository on Tangled..." -- \ 440 + ${pkgs.curl}/bin/curl -s 'https://tangled.org/repo/new' \ 441 + -H 'Accept: */*' \ 442 + -H 'Content-Type: application/x-www-form-urlencoded' \ 443 + -b "appview-session-v2=$tangled_cookie" \ 444 + -H 'HX-Current-URL: https://tangled.org/repo/new' \ 445 + -H 'HX-Request: true' \ 446 + -H 'Origin: https://tangled.org' \ 447 + -H 'Referer: https://tangled.org/repo/new' \ 448 + --data-raw "name=''${repo_name}&description=''${encoded_desc}&branch=''${default_branch}&domain=''${tangled_domain}" \ 449 + > /tmp/tangled-response-$$.html 450 + 451 + if grep -q "error\|Error\|failed\|Failed" /tmp/tangled-response-$$.html 2>/dev/null; then 452 + ${pkgs.gum}/bin/gum style --foreground 196 "✗ Failed to create Tangled repository" 453 + ${pkgs.gum}/bin/gum style --foreground 196 " Check /tmp/tangled-response-$$.html for details" 454 + else 455 + ${pkgs.gum}/bin/gum style --foreground 35 "✓ Created on Tangled: https://tangled.org/$tangled_domain/$repo_name" 456 + 457 + # Add tangled remote 458 + plc_id=$(${pkgs.gum}/bin/gum input --placeholder "$default_plc_id" --prompt "PLC ID: " --value "$default_plc_id") 459 + plc_id=''${plc_id:-$default_plc_id} 460 + 461 + if ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null; then 462 + if ${pkgs.git}/bin/git remote get-url origin &>/dev/null; then 463 + ${pkgs.gum}/bin/gum style --foreground 214 "Origin already exists, adding as 'tangled' remote" 464 + ${pkgs.git}/bin/git remote add tangled "git@$default_knot_host:''${plc_id}/''${repo_name}" 2>/dev/null || \ 465 + ${pkgs.git}/bin/git remote set-url tangled "git@$default_knot_host:''${plc_id}/''${repo_name}" 466 + else 467 + ${pkgs.git}/bin/git remote add origin "git@$default_knot_host:''${plc_id}/''${repo_name}" 468 + fi 469 + fi 470 + 471 + rm -f /tmp/tangled-response-$$.html 472 + fi 473 + fi 474 + fi 475 + 476 + # Create on GitHub 477 + if ${pkgs.gum}/bin/gum confirm "Create on GitHub?"; then 478 + gh_flags="" 479 + [[ "$visibility" == "public" ]] && gh_flags="--public" || gh_flags="--private" 480 + [[ -n "$description" ]] && gh_flags="$gh_flags --description \"$description\"" 481 + 482 + ${pkgs.gum}/bin/gum spin --spinner dot --title "Creating repository on GitHub..." -- \ 483 + bash -c "${pkgs.gh}/bin/gh repo create \"$repo_name\" $gh_flags --clone 2>&1" > /tmp/gh-response-$$.txt 484 + 485 + if [[ $? -eq 0 ]]; then 486 + ${pkgs.gum}/bin/gum style --foreground 35 "✓ Created on GitHub" 487 + 488 + # If we weren't in a git repo before, cd into the new one 489 + if ! ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null && [[ -d "$repo_name" ]]; then 490 + cd "$repo_name" 491 + ${pkgs.gum}/bin/gum style --foreground 117 "Changed to directory: $repo_name" 492 + fi 493 + 494 + # Add github remote if it doesn't exist 495 + if ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null; then 496 + if ! ${pkgs.git}/bin/git remote get-url github &>/dev/null; then 497 + github_url=$(${pkgs.git}/bin/git remote get-url origin 2>/dev/null | ${pkgs.gnused}/bin/sed 's/origin/github/') 498 + if [[ -n "$github_url" && "$github_url" == *"github.com"* ]]; then 499 + ${pkgs.git}/bin/git remote add github "$github_url" 2>/dev/null || true 500 + fi 501 + fi 502 + fi 503 + else 504 + ${pkgs.gum}/bin/gum style --foreground 196 "✗ Failed to create GitHub repository" 505 + cat /tmp/gh-response-$$.txt 506 + fi 507 + 508 + rm -f /tmp/gh-response-$$.txt 509 + fi 510 + 511 + echo 512 + ${pkgs.gum}/bin/gum style --bold --foreground 35 "Done!" 513 + 514 + # Show remotes 515 + if ${pkgs.git}/bin/git rev-parse --is-inside-work-tree &>/dev/null; then 516 + echo 517 + ${pkgs.gum}/bin/gum style --bold "Git remotes:" 518 + ${pkgs.git}/bin/git remote -v 519 + fi 520 + ''; 521 + 376 522 in 377 523 { 378 524 options.atelier.shell.enable = lib.mkEnableOption "Custom shell config"; ··· 509 655 gc = "git commit"; 510 656 gp = "git push"; 511 657 rr = "rm -Rf"; 512 - ghrpc = "gh repo create -c"; 513 658 goops = "git commit --amend --no-edit && git push --force-with-lease"; 514 659 vi = "nvim"; 515 660 vim = "nvim"; ··· 708 853 709 854 home.packages = with pkgs; [ 710 855 tangled-setup 856 + ghrpc 711 857 assh 712 858 hackatime-summary 713 859 now
+3
secrets/secrets.nix
··· 77 77 "pbnj.age".publicKeys = [ 78 78 kierank 79 79 ]; 80 + "tangled-session.age".publicKeys = [ 81 + kierank 82 + ]; 80 83 }
secrets/tangled-session.age

This is a binary file and will not be displayed.