Skip to content

Commit

Permalink
add go example
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Webber <sebastian@swebber.me>
  • Loading branch information
sebastianwebber committed Sep 11, 2024
1 parent 39bf6ce commit dcfc03e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/go/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0="

use devenv
9 changes: 9 additions & 0 deletions examples/go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml
13 changes: 13 additions & 0 deletions examples/go/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs, name, version, ... }:
pkgs.buildGoApplication {
pname = name;
version = version;

src = builtins.path {
path = ./.;
name = "source";
};

## remember to call 'gomod2nix' to generate this file
modules = ./gomod2nix.toml;
}
26 changes: 26 additions & 0 deletions examples/go/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ pkgs, lib, config, inputs, ... }:

{
packages = [ pkgs.git pkgs.gomod2nix ];

languages.go.enable = true;

pre-commit.hooks = {
govet = {
enable = true;
pass_filenames = false;
};
gotest.enable = true;
golangci-lint = {
enable = true;
pass_filenames = false;
};
};

outputs = let
name = "my-app";
version = "1.0.0";
in { app = import ./default.nix { inherit pkgs name version; }; };

# See full reference at https://devenv.sh/reference/options/
}
10 changes: 10 additions & 0 deletions examples/go/devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
gomod:
url: github:nix-community/gomod2nix
overlays:
- default
# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true

0 comments on commit dcfc03e

Please sign in to comment.