cmd/devenv.nix

46 lines
982 B
Nix

{ pkgs, ... }:
{
# https://devenv.sh/basics/
env.NAME = "cmd";
# https://devenv.sh/packages/
packages = with pkgs; [
git
gotest
];
# https://devenv.sh/scripts/
scripts.welcome-banner.exec = ''
echo "Welcome to the $NAME development environment."
echo -n "Golang version: $(go version | cut -d ' ' -f 3), "
'';
scripts.run-tests.exec = ''
gotest ./...
'';
scripts.cover.exec = ''
go test -race -cover -covermode=atomic -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o=coverage.html
'';
scripts.cover-open.exec = ''
cover
xdg-open coverage.html &>/dev/null
'';
enterShell = "welcome-banner";
# https://devenv.sh/languages/
languages.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";
# See full reference at https://devenv.sh/reference/options/
}