added helper script

This commit is contained in:
Jakub Kropáček 2025-07-08 01:05:31 +02:00
parent ab59b485cd
commit b09a2d5612
Signed by: JustScreaMy
GPG key ID: 4EC6A2C45D75FC86
4 changed files with 70 additions and 0 deletions

View file

@ -82,6 +82,7 @@
uv-bin = pkgs.callPackage ./packages/uv { }; uv-bin = pkgs.callPackage ./packages/uv { };
lanshare = pkgs.callPackage ./packages/lanshare { }; lanshare = pkgs.callPackage ./packages/lanshare { };
warpssh = pkgs.callPackage ./packages/warpssh { }; warpssh = pkgs.callPackage ./packages/warpssh { };
whst = pkgs.callPackage ./packages/whst { };
}; };
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
hydraJobs = { hydraJobs = {

View file

@ -33,6 +33,7 @@ in
rpi-imager rpi-imager
wireguard-tools wireguard-tools
warpssh warpssh
whst
]; ];
programs.go = { programs.go = {
enable = true; enable = true;

View file

@ -8,6 +8,7 @@ in
uv-bin = self.packages.x86_64-linux.uv-bin; uv-bin = self.packages.x86_64-linux.uv-bin;
lanshare = self.packages.x86_64-linux.lanshare; lanshare = self.packages.x86_64-linux.lanshare;
warpssh = self.packages.x86_64-linux.warpssh; warpssh = self.packages.x86_64-linux.warpssh;
whst = self.packages.x86_64-linux.whst;
kropcloud-utils = inputs.kropcloud-utils.packages.x86_64-linux.default; kropcloud-utils = inputs.kropcloud-utils.packages.x86_64-linux.default;
gamescope = prev.gamescope.overrideAttrs (oldAttrs: { gamescope = prev.gamescope.overrideAttrs (oldAttrs: {
patches = (oldAttrs.patches or [ ]) ++ [ patches = (oldAttrs.patches or [ ]) ++ [

67
packages/whst/default.nix Normal file
View file

@ -0,0 +1,67 @@
{
writeShellScriptBin,
}:
writeShellScriptBin "whst" ''
print_help () {
cat << EOF
Usage: whst <status_code> [options]
Check the meaning or details of a given HTTP status code.
Arguments:
status_code Integer HTTP status code to look up (e.g., 200, 404).
Options:
-h Show this help message and exit.
Examples:
whst 200
whst 404 -h
EOF
}
OPTSTRING="h"
while getopts "$OPTSTRING" opt; do
case "$opt" in
h)
print_help
exit 0
;;
?)
echo "Invalid option: -$OPTARG." >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
if (( $# < 1 )); then
echo "Error: Missing required status_code argument." >&2
echo "Use -h for help." >&2
exit 1
fi
status_code="$1"
if ! [[ "$status_code" =~ ^[0-9]+$ ]]; then
echo "Error: status_code must be an integer." >&2
exit 1
fi
url="https://http.cat/$status_code"
xdg-open "$url" >/dev/null 2>&1
ret=$?
if (( ret != 0 )); then
echo "Failed to open browser automatically. Here's the URL instead:"
echo "$url"
exit 1
fi
exit 0
''