Working with Modules
Modules are the building blocks of your set-me-up environment
Available Modules
Pre-built modules to set up your development environment
Core Module
Application Modules
Development Environment Modules
Advanced Usage
Install Multiple Modules
You can provision multiple modules at once by specifying multiple --module flags:
smu --provision --module app_store --module casks --module php --no-base
Module Execution Flow
Understanding how modules are executed
before.sh
(if exists)Pre-installation tasks and environment preparation
Runs first if present in module directory
module.sh
RequiredMain installation script with core module logic
The heart of every module - must exist
brewfile
(if exists)Homebrew bundle installation of packages and apps
Processes Homebrew bundle if file exists
after.sh
(if exists)Post-installation configuration and cleanup
Runs last if present - final setup tasks
Only module.sh is required. The other scripts (before.sh, brewfile, after.sh) are optional and will only execute if they exist in your module directory.
Creating Custom Modules
Build your own modules for specialized installations
Basic Module
Create a simple module with a main script:
# Create module directory
mkdir -p ~/set-me-up/modules/mymodule
# Create the main script
cat > ~/set-me-up/modules/mymodule/module.sh << 'EOF'
#!/bin/bash
echo "Installing my custom tools..."
brew install tool1 tool2
EOF
chmod +x ~/set-me-up/modules/mymodule/module.sh
# Provision your module
smu --provision --module mymodule --no-base
Module with Brewfile
Add a brewfile for package management:
# Create the brewfile
cat > ~/set-me-up/modules/mymodule/brewfile << 'EOF'
# CLI tools
brew "tool1"
brew "tool2"
# GUI applications
cask "application1"
cask "application2"
EOF
The brewfile will be automatically processed during provisioning
Module with Hooks
Add before and after hooks for custom logic:
# Before hook (runs first)
cat > ~/set-me-up/modules/mymodule/before.sh << 'EOF'
#!/bin/bash
echo "Preparing environment..."
# Pre-installation tasks
EOF
# After hook (runs last)
cat > ~/set-me-up/modules/mymodule/after.sh << 'EOF'
#!/bin/bash
echo "Finalizing setup..."
# Post-installation tasks
EOF
chmod +x ~/set-me-up/modules/mymodule/*.sh
Module Best Practices
Guidelines for creating reliable and maintainable modules
Example: Idempotent Module
A well-structured module that can be run safely multiple times
#!/bin/bash
# Check if already installed
if command -v mytool &> /dev/null; then
echo "mytool is already installed"
exit 0
fi
echo "Installing mytool..."
brew install mytool
# Verify installation
if command -v mytool &> /dev/null; then
echo "✓ mytool installed successfully"
else
echo "✗ mytool installation failed"
exit 1
fi
Ready to Explore More?
Learn about dotfile management and customization