go-twitch/devenv.nix

73 lines
1.8 KiB
Nix
Raw Normal View History

2024-03-03 17:12:13 -05:00
{ pkgs, ... }:
{
# https://devenv.sh/basics/
env = {
PROJECT_NAME = "go-twitch";
2024-03-03 17:12:13 -05:00
MOCK_DATA_PATH = "~/.config/twitch-cli/eventCache.db";
MOCK_API_PORT = "3000";
CHANGELOG_FILE = "CHANGELOG.md";
};
2024-03-03 17:12:13 -05:00
# https://devenv.sh/packages/
packages = with pkgs; [
git
git-cliff
2024-03-03 17:12:13 -05:00
twitch-cli
];
# https://devenv.sh/scripts/
scripts = {
welcome-banner.exec = ''
echo "Welcome to the $PROJECT_NAME development environment."
echo "Golang version: $(go version | cut -d ' ' -f 3)"
'';
gen-changelog.exec = "git cliff -o $CHANGELOG_FILE";
release.exec = ''
set -euo pipefail
if [ -n "$(git status --porcelain)" ]; then
printf "Working directory is not clean. Please commit or stash your changes.\n"
exit 1
fi
version="$(git cliff --bumped-version)"
changelog=$(git cliff --unreleased --strip all | sed -e '/^#/d' -e '/^$/d')
2024-03-08 13:50:39 -05:00
git cliff --bump --unreleased --prepend $CHANGELOG_FILE
git add $CHANGELOG_FILE
git commit -m "chore(release): release $version"
git tag "$version" -m "Release $version" -m "$changelog"
git push --tags
'';
2024-03-03 17:12:13 -05:00
gen-mock-data.exec = "twitch-cli mock-api generate";
rm-mock-data.exec = "rm $MOCK_DATA_PATH";
start-mock-api.exec = "twitch-cli mock-api start -p $MOCK_API_PORT";
};
enterShell = "welcome-banner";
# https://devenv.sh/languages/
languages = {
nix.enable = true;
go.enable = true;
};
# https://devenv.sh/pre-commit-hooks/
# pre-commit.hooks.shellcheck.enable = true;
# https://devenv.sh/processes/
# processes.ping.exec = "ping example.com";
process.before = ''
if [ ! -f $MOCK_DATA_PATH ]; then
gen-mock-data
fi
'';
processes.mock-api.exec = "start-mock-api";
# See full reference at https://devenv.sh/reference/options/
}