Scripts of various kinds (but also other scripts)
| deno | ||
| python | ||
| .gitignore | ||
| README.md | ||
Scripts! just scripts!
A collection of utility scripts in various languages (Deno/TypeScript, Python, Node.js), nixified for easy execution.
Prerequisites
Just Nix - that's it! Each script bundles its own dependencies.
Usage
Scripts are now organized by language in subdirectories. Run them directly from their respective folders:
# Clone the repo
git clone https://github.com/JulianNymark/scripts.git
cd scripts
# Run any script - Nix will fetch dependencies automatically
./deno/nix-search-formatter.ts <search-term>
./deno/thumbnailify_cwd.ts
./python/image_to_uint16_array_4bpc_GBAR.py input.png -o output.txt
First run will be slow as Nix downloads dependencies, but subsequent runs are instant.
Scripts
- deno/nix-search-formatter.ts - Formats nix search output for easier reading (Deno)
- deno/thumbnailify_cwd.ts - Creates thumbnails for images and videos in current directory (Deno, ffmpeg)
- python/image_to_uint16_array_4bpc_GBAR.py - Converts images to uint16 arrays (Python, PIL, numpy)
Adding New Scripts
- Create your script with a nix-shell shebang at the top:
TypeScript/Deno:
#!/usr/bin/env nix-shell
/*
#! nix-shell -i "deno run --allow-read --allow-write" -p deno
*/
// your code here
Python:
#!/usr/bin/env nix-shell
#! nix-shell -i python3 -p "python3.withPackages (ps: [ ps.numpy ps.pillow ])"
# your code here
Node.js:
#!/usr/bin/env nix-shell
/*
#! nix-shell -i node -p nodejs
*/
// your code here
Bash:
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p curl jq ffmpeg
# your code here
- Make it executable:
chmod +x your-script.ext - Run it:
./your-script.ext
That's it! No flake updates needed. Each script manages its own dependencies.
How It Works
The nix-shell shebang tells Nix:
-i <interpreter>: What interpreter to use-p <packages>: What packages to provide in the environment
Nix creates an isolated environment with exactly those dependencies, then runs your script.