1
0
Fork 0

feat(scripts): Add script to get a Minecraft account UUID

This commit is contained in:
Avery 2025-07-22 13:17:19 +02:00
parent deab672810
commit a380da80a1
Signed by: Avery
GPG key ID: B684FD451B692E04
3 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,5 @@
{ pkgs, ... }: {
imports = [ ./development.nix ./zsh.nix ];
imports = [ ./development.nix ./scripts ./zsh.nix ];
home = {
username = "avery";
homeDirectory = "/home/avery";

View file

@ -0,0 +1,3 @@
{ pkgs, ... }: {
home.packages = [ (import ./get-minecraft-uuid.nix { inherit pkgs; }) ];
}

View file

@ -0,0 +1,16 @@
{ pkgs }:
pkgs.writeShellApplication {
name = "get-minecraft-uuid";
runtimeInputs = with pkgs; [ curl jq gnused ];
text = ''
usage() {
echo "USAGE: get-minecraft-uuid USERNAME"
exit 1
}
test -n "$1" || usage
curl -s "https://api.mojang.com/users/profiles/minecraft/$1" | jq -r ".id" | sed -r "s/^(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})$/\1-\2-\3-\4-\5/"
'';
}