nix-templates/go/flake.nix

37 lines
889 B
Nix
Raw Normal View History

2022-06-11 16:01:36 +01:00
{
description = "Another cool golang abhorration from samw";
2022-08-03 23:40:52 +01:00
inputs.utils.url = "github:numtide/flake-utils";
2023-04-18 00:30:20 +01:00
inputs.devshell.url = "github:numtide/devshell";
2022-06-11 16:01:36 +01:00
2022-06-19 15:20:35 +01:00
outputs = {
self,
nixpkgs,
utils,
devshell,
}:
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
2023-02-28 17:12:42 +00:00
overlays = [devshell.overlays.default];
2022-06-19 15:20:35 +01:00
};
in rec {
packages.default = pkgs.buildGoModule {
name = "my-project";
src = self;
vendorSha256 = "";
2022-06-11 16:01:36 +01:00
2022-06-19 15:20:35 +01:00
# Inject the git version if you want
#ldflags = ''
# -X main.version=${if self ? rev then self.rev else "dirty"}
#'';
};
2022-06-11 16:01:36 +01:00
2022-06-19 15:20:35 +01:00
apps.default = utils.lib.mkApp {drv = packages.default;};
2022-06-11 16:01:36 +01:00
2022-06-19 15:20:35 +01:00
devShells.default =
pkgs.devshell.mkShell {packages = with pkgs; [go gopls];};
formatter = pkgs.alejandra;
2022-06-19 15:20:35 +01:00
});
2022-06-11 16:01:36 +01:00
}