88 lines
2.3 KiB
Nix
88 lines
2.3 KiB
Nix
{ pkgs, ... }:
|
|
|
|
{
|
|
# https://devenv.sh/basics/
|
|
env.NAME = "ytdl-web";
|
|
env.BINARY_OUT = "./out/ytdl-web";
|
|
env.VERSION = "1.0.8";
|
|
env.VERSION_PKG = "go.fifitido.net/ytdl-web/version";
|
|
env.DOCKER_REGISTRY = "git.fifitido.net";
|
|
env.DOCKER_ORG = "apps";
|
|
env.DOCKER_PLATFORMS = "linux/amd64,linux/arm64";
|
|
|
|
env.YTDL_ENV = "Development";
|
|
|
|
# https://devenv.sh/packages/
|
|
packages = with pkgs; [
|
|
git
|
|
air
|
|
docker
|
|
docker-compose
|
|
buildkit
|
|
docker-buildx
|
|
yt-dlp
|
|
];
|
|
|
|
# https://devenv.sh/scripts/
|
|
scripts.deps.exec = "go mod download";
|
|
scripts.tidy.exec = "go mod tidy";
|
|
|
|
scripts.build-id = "git rev-parse --short HEAD";
|
|
scripts.build-date = "date -Iseconds";
|
|
|
|
scripts.build.exec = ''
|
|
go build -ldflags="
|
|
-X $VERSION_PKG.Version=$VERSION
|
|
-X $VERSION_PKG.Build=$(build-id)
|
|
-X $VERSION_PKG.BuildDate=$(build-date)
|
|
-X $VERSION_PKG.BuiltBy=manual
|
|
" -o $BINARY_OUT .
|
|
'';
|
|
scripts.clean.exec = ''
|
|
rm -rf ./dist/ ./out/ ./tmp/
|
|
go clean
|
|
'';
|
|
scripts.lint.exec = "trunk check";
|
|
scripts.fmt.exec = "trunk fmt";
|
|
|
|
scripts.docker-image.exec = "echo $DOCKER_REGISTRY/$DOCKER_ORG/$NAME";
|
|
|
|
scripts.docker-init.exec = ''
|
|
docker buildx create \
|
|
--name $NAME \
|
|
--platform $DOCKER_PLATFORMS
|
|
'';
|
|
|
|
scripts.docker-build-release.exec = ''
|
|
docker-init
|
|
docker buildx build \
|
|
--tag $(docker-image):$VERSION \
|
|
--tag $(docker-image):latest \
|
|
--platform $DOCKER_PLATFORMS \
|
|
--builder $NAME \
|
|
--build-arg VERSION=$VERSION
|
|
--build-arg BUILD=$(build-id)
|
|
--build-arg BUILD_DATE=$(build-date)
|
|
'';
|
|
|
|
enterShell = ''
|
|
echo "Welcome to the $NAME development environment."
|
|
echo -n "Golang version: $(go version | cut -d ' ' -f 3), "
|
|
echo -n "Docker CLI version: $(docker version -f {{.Client.Version}}), "
|
|
echo -n "Buildx version: $(docker buildx version | cut -d ' ' -f 2), "
|
|
echo "yt-dlp version: $(yt-dlp --version)"
|
|
'';
|
|
|
|
# https://devenv.sh/languages/
|
|
languages.go.enable = true;
|
|
|
|
# https://devenv.sh/pre-commit-hooks/
|
|
pre-commit.hooks.staticcheck.enable = true;
|
|
pre-commit.hooks.hadolint.enable = true;
|
|
pre-commit.hooks.yamllint.enable = true;
|
|
|
|
# https://devenv.sh/processes/
|
|
processes.web.exec = "air";
|
|
|
|
# See full reference at https://devenv.sh/reference/options/
|
|
} |