ytdl-web/devenv.nix

67 lines
1.7 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.YTDL_ENV = "Development";
# https://devenv.sh/packages/
packages = with pkgs; [
git
air
goreleaser
docker
docker-compose
trunk-io
yt-dlp
];
# https://devenv.sh/scripts/
scripts.deps.exec = "go mod download";
scripts.tidy.exec = "go mod tidy";
scripts.check.exec = "goreleaser check";
scripts.build.exec = ''
go build -ldflags="
-X $VERSION_PKG.Version=$VERSION
-X $VERSION_PKG.Build=$(git rev-parse --short HEAD)
-X $VERSION_PKG.BuildDate=$(date -Iseconds)
-X $VERSION_PKG.BuiltBy=taskfile
" -o $BINARY_OUT .
'';
scripts.clean.exec = ''
rm -rf ./dist/ ./out/ ./tmp/
go clean
'';
scripts.release.exec = ''
clean
goreleaser release
'';
scripts.lint.exec = "trunk check";
scripts.fmt.exec = "trunk fmt";
enterShell = ''
echo "Welcome to the $NAME development environment."
echo -n "Golang version: $(go version | cut -d ' ' -f 3), "
echo -n "Goreleaser version: $(goreleaser --version | tail -n 9 | head -n 1 | cut -c 16-), "
echo -n "yt-dlp version: $(yt-dlp --version), "
echo "Trunk version: $(trunk --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/
}