From 9513ccefe5cb4984246fe155fd3e43bf2ea33eac Mon Sep 17 00:00:00 2001 From: Sebastian Webber Date: Wed, 11 Sep 2024 16:42:41 -0300 Subject: [PATCH 1/2] add go example Signed-off-by: Sebastian Webber --- examples/go/default.nix | 13 +++++++++++++ examples/go/devenv.nix | 26 ++++++++++++++++++++++++++ examples/go/devenv.yaml | 10 ++++++++++ 3 files changed, 49 insertions(+) create mode 100644 examples/go/default.nix create mode 100644 examples/go/devenv.nix create mode 100644 examples/go/devenv.yaml diff --git a/examples/go/default.nix b/examples/go/default.nix new file mode 100644 index 000000000..eb20c3d1d --- /dev/null +++ b/examples/go/default.nix @@ -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; +} diff --git a/examples/go/devenv.nix b/examples/go/devenv.nix new file mode 100644 index 000000000..77531dc45 --- /dev/null +++ b/examples/go/devenv.nix @@ -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/ +} diff --git a/examples/go/devenv.yaml b/examples/go/devenv.yaml new file mode 100644 index 000000000..c9ed906e5 --- /dev/null +++ b/examples/go/devenv.yaml @@ -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 From 230684a99b2ff6fda56300e1108220466bc661f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Fri, 20 Sep 2024 11:00:13 +0100 Subject: [PATCH 2/2] fix go formatting --- examples/go/devenv.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/go/devenv.nix b/examples/go/devenv.nix index 77531dc45..23ea6958c 100644 --- a/examples/go/devenv.nix +++ b/examples/go/devenv.nix @@ -17,10 +17,12 @@ }; }; - outputs = let - name = "my-app"; - version = "1.0.0"; - in { app = import ./default.nix { inherit pkgs name version; }; }; + 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/ }