diff --git a/common/home-manager/default.nix b/common/home-manager/default.nix index d1fa255..c12be25 100644 --- a/common/home-manager/default.nix +++ b/common/home-manager/default.nix @@ -1,5 +1,5 @@ { pkgs, ... }: { - imports = [ ./development.nix ./zsh.nix ]; + imports = [ ./development.nix ./scripts ./zsh.nix ]; home = { username = "avery"; homeDirectory = "/home/avery"; diff --git a/common/home-manager/scripts/default.nix b/common/home-manager/scripts/default.nix new file mode 100644 index 0000000..5e6bd14 --- /dev/null +++ b/common/home-manager/scripts/default.nix @@ -0,0 +1,3 @@ +{ pkgs, ... }: { + home.packages = [ (import ./get-minecraft-uuid.nix { inherit pkgs; }) ]; +} diff --git a/common/home-manager/scripts/get-minecraft-uuid.nix b/common/home-manager/scripts/get-minecraft-uuid.nix new file mode 100644 index 0000000..c6670cc --- /dev/null +++ b/common/home-manager/scripts/get-minecraft-uuid.nix @@ -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/" + ''; +}