Babashka-powered build tool with Grain Network branding
"Pragmatic Branding Over Dogmatic Renaming" - gb command, bb.edn files (Babashka requirement)
"Feeling like a leaf in the wind but feeling like a rock"
Grainbarrel (gb) is a thin wrapper around Babashka (bb) that provides Grain Network-specific enhancements, task organization, and a consistent command-line interface across all Grain projects.
The Chaos/Solidity Dynamic:
- External: Calm chaos flowing out (creative expression, 7 modules in 72 hours)
- Internal: Solid core staying grounded (pure functional architecture, core values)
- Observer: You, watching yourself create, documenting the journey
- Together: Productive creativity from stable center
Babashka is an excellent fast-starting Clojure scripting environment, but Grainbarrel adds:
- πΎ Grain Network Branding -
gbinstead ofbbfor all Grain projects - π¦ Task Registry - Centralized task definitions across grainstore modules
- π Cross-Module Tasks - Run tasks across multiple grainstore modules
- π¨ Enhanced Output - Grain-themed formatting and progress indicators
- π Dependency Management - Automatic grainstore module dependency resolution
- π Task Discovery - Search and explore available tasks
- π Documentation Integration - Inline help and markdown generation
# Create symlink in your local bin
ln -s $(which bb) ~/.local/bin/gb
# Or install system-wide
sudo ln -s $(which bb) /usr/local/bin/gb# Install Grainbarrel wrapper
cd grainstore/grainbarrel
bb install
# This creates ~/.local/bin/gb with enhanced featuresGrainbarrel is 100% compatible with Babashka - all bb commands work with gb:
# Standard Babashka usage
gb script.clj
gb -e '(println "Hello Grain!")'
gb tasks
gb task-name
# Grainbarrel enhancements
gb grainstore:list # List all grainstore modules
gb grainstore:update # Update all modules
gb icon install cursor # grainicons task
gb cask install cursor # graincasks task
gb display:info # graindisplay task
gb nightlight:enable # grain-nightlight task| Feature | bb (Babashka) |
gb (Grainbarrel) |
|---|---|---|
| Core functionality | β Full Clojure scripting | β Same (wrapper around bb) |
| Task execution | β
bb.edn tasks |
β Same + cross-module tasks |
| Speed | β Fast startup | β Same performance |
| Branding | Babashka | πΎ Grain Network |
| Module tasks | Manual navigation | β Run from anywhere |
| Task discovery | bb tasks per project |
β Global task registry |
| Documentation | External docs | β
Inline gb help |
Run tasks from any grainstore module without cd:
# Instead of:
cd grainstore/grainicons && bb icon install cursor
# Use:
gb icon install cursor # Works from anywhere!All grainstore module tasks are registered:
# List all available tasks across all modules
gb tasks:all
# Search for tasks
gb tasks:search icon
# Show task help
gb help icon:install# List grainstore modules
gb grainstore:list
# Update a specific module
gb grainstore:update grainicons
# Verify module dependencies
gb grainstore:verify
# Create new module
gb grainstore:new my-moduleGrain-themed formatting:
πΎ Grainbarrel v1.0.0 (Babashka v1.3.191)
Running task: icon:install cursor
π¦ Installing icon: cursor-grain
β
Generated cursor-grain-512.png
β
Generated cursor-grain-256.png
β
Installed to ~/.local/share/icons/
πΎ Success!Global configuration in ~/.config/grainbarrel/config.edn:
{:grainbarrel
{:version "1.0.0"
:paths
{:grainstore "~/kae3g/grainkae3g/grainstore"
:modules-config "grainstore/grainstore.edn"}
:output
{:theme :grain ;; :grain, :minimal, :verbose
:color true
:emoji true
:progress-bars true}
:tasks
{:auto-discover true ;; Auto-discover tasks from modules
:namespace-prefix "gb" ;; Prefix for task namespaces
:show-hidden false} ;; Show hidden/internal tasks
:modules
{:auto-load true ;; Load all grainstore modules
:verify-deps true} ;; Check dependencies on load
:babashka
{:version-min "1.3.0"
:jvm-opts ["-Xmx2g"]}}}Grainbarrel uses namespaced task names:
module:task-name
Examples:
- icon:install (from grainicons)
- icon:generate (from grainicons)
- cask:install (from graincasks)
- cask:update (from graincasks)
- display:info (from graindisplay)
- display:set-scaling (from graindisplay)
- nightlight:enable (from grain-nightlight)
- grainstore:list (from grainbarrel itself)
The gb wrapper script (bin/gb):
#!/usr/bin/env bash
# Grainbarrel - Grain Network Build System
# Wrapper around Babashka with enhanced features
# Grain Network branding
export GRAINBARREL_VERSION="1.0.0"
export GRAINBARREL_HOME="${GRAINBARREL_HOME:-$HOME/.config/grainbarrel}"
# Check if babashka is installed
if ! command -v bb &> /dev/null; then
echo "πΎ Grainbarrel requires Babashka (bb) to be installed."
echo " Install from: https://babashka.org"
exit 1
fi
# Grainbarrel-specific commands
case "$1" in
--version|-v)
echo "πΎ Grainbarrel v${GRAINBARREL_VERSION} (Babashka $(bb --version | cut -d' ' -f2))"
exit 0
;;
help)
if [ -z "$2" ]; then
echo "πΎ Grainbarrel - Grain Network Build System"
echo ""
echo "Usage: gb [task|script] [args...]"
echo ""
echo "Grainbarrel Commands:"
echo " gb tasks:all List all tasks across grainstore modules"
echo " gb grainstore:list List all grainstore modules"
echo " gb help [task] Show help for a specific task"
echo ""
echo "For full Babashka help: bb --help"
else
# Show help for specific task
bb -e "(require '[grainbarrel.help :as help]) (help/show-task \"$2\")"
fi
exit 0
;;
esac
# Pass through to babashka with Grainbarrel context
export GRAINBARREL_ACTIVE=true
bb "$@"Grainbarrel reads grainstore/grainstore.edn to discover modules and tasks:
;; Auto-loaded tasks from grainstore modules
{:modules
{:grainicons
{:tasks
{:install "Install icon from library"
:generate "Generate PNG sizes from SVG"
:list "List available icons"}}
:graincasks
{:tasks
{:install "Install AppImage cask"
:update "Update installed casks"
:list "List installed casks"}}
:graindisplay
{:tasks
{:info "Show display information"
:set-scaling "Set text scaling factor"
:nightlight "Toggle night light"}}}}Grainbarrel is backward compatible - existing bb.edn files work as-is:
# Old way (still works)
cd grainstore/grainicons
bb icon:install cursor
# New way (works from anywhere)
gb icon:install cursor
# Both commands are equivalent!No changes needed to your existing bb.edn files.
gb grainstore:list # List modules
gb grainstore:update # Update all
gb grainstore:verify # Verify dependencies
gb grainstore:doc # Generate docsgb icon:install cursor # Install icon
gb icon:generate cursor # Generate PNGs
gb icon:list # List icons
gb icon:cache:clear # Clear cachegb cask:install cursor # Install AppImage
gb cask:update # Update all casks
gb cask:list # List installed
gb cask:uninstall cursor # Remove caskgb display:info # Show display info
gb display:set-scaling 1.5 # Set scaling
gb display:nightlight 2000 # Set color temp
gb display:profile reading # Switch profilegb nightlight:enable # Enable night light
gb nightlight:status # Check status
gb wifi:status # Check wifi
gb wifi:switch # Switch connection
gb daemon:status # Check daemons- Grain = Grain Network branding
- Barrel = Container/storage (like Babashka's pod/barrel concept)
gb= Short, memorable, available command name- Barrels store grain = Metaphor for grainstore modules
| Tool | Language | Speed | Use Case | Grain Network |
|---|---|---|---|---|
| Make | Shell | Fast | C/Unix builds | β Not Clojure |
| Leiningen | Clojure | Slow startup | JVM projects | β Too slow |
| Babashka | Clojure | Very fast | Scripting | β Perfect! |
| Grainbarrel | Clojure | Very fast | Grain Network | πΎ This! |
Grainbarrel is written in Babashka Clojure:
;; src/grainbarrel/core.clj
(ns grainbarrel.core
(:require [babashka.tasks :as tasks]))
(defn discover-modules
"Discover all grainstore modules and their tasks"
[]
(-> (slurp "grainstore/grainstore.edn")
(edn/read-string)
:grainstore
:modules))
(defn run-task
"Run a namespaced task from any module"
[task-name & args]
(let [[module task] (str/split task-name #":")]
(tasks/run-task (keyword module) (keyword task) args)))- Task Composition: Chain tasks together
- Parallel Execution: Run multiple tasks in parallel
- Watch Mode: Auto-run tasks on file changes
- Remote Execution: Run tasks on remote Grain Network nodes
- Task Templates: Reusable task patterns
- Plugin System: Extend Grainbarrel with custom modules
MIT License - See LICENSE file for details
- Babashka: The underlying Clojure scripting engine
- grainstore: Module and dependency management
- graincasks: AppImage package manager
- grainicons: Icon management library
- graindisplay: Display configuration system
Part of the Grain Network - Global Renewable technology for a sustainable future πΎ
"From bb to gb - Grain Network builds with barrels of Clojure."