Nix flakes on the AT protocol
3

Configure Feed

Select the types of activity you want to include in your feed.

feat: finished initial implementation for nixat

+18 -4
+18 -4
nixat
··· 1 1 #!/usr/bin/env bash 2 + # 3 + # This file will publish and build flakes that are on atproto 2 4 3 5 set -euo pipefail 4 6 7 + check_command() { 8 + if ! command -v $1 >/dev/null 2>&1; then 9 + echo "Missing command $1" 10 + echo "Install it and try this again or alternatively, try building this through the flake." 11 + exit 1 12 + fi 13 + } 14 + 15 + check_command goat 16 + check_command git 17 + check_command jq 18 + 5 19 check_login() { 6 20 if ! goat account check-auth >/dev/null 2>&1; then 7 21 echo "Please make sure you have logged in before-hand. Try:" ··· 24 38 record="$(goat get "$aturi")" 25 39 source="$(jq -r '.source' <<<"$record")" 26 40 rev="$(jq -r '.rev' <<<"$record")" 41 + narHash="$(jq -r '.narHash' <<<"$record")" 27 42 28 - echo "TODO: this is broken" 29 - exit 1 30 - # nix build "git+ssh://${source}?rev=${rev}" "$@" 43 + defaultFileContent="$(printf 'let src = builtins.fetchGit { url = "%s"; rev = "%s"; }; in assert src.narHash == "%s"; src.outPath' "$source" "$rev" "$narHash")" 44 + srcPath="$(nix eval --expr "$defaultFileContent" | sed -r 's/\"([^\"]+)\"/\1/')" 45 + nix build "$srcPath" 31 46 } 32 47 33 48 publish() { ··· 42 57 narHash="$(nix flake metadata --json "git+file://${path}?rev=${rev}" | jq -r .locked.narHash)" 43 58 publishedAt="$(date -u +%Y-%m-%dT%H:%M:%SZ)" 44 59 45 - check_login 46 60 record="$(printf '{"$type":"space.stau.nix.release","rev":"%s","source":"%s","narHash":"%s","publishedAt":"%s"}' "$rev" "$source" "$narHash" "$publishedAt")" 47 61 jq -n "$record" | goat record create --rkey "$version" --no-validate - 48 62 }