nix-templates/go/flake.nix

40 lines
929 B
Nix

{
description = "Another cool golang abhorration from samw";
inputs.utils.url = "github:numtide/flake-utils";
inputs.devshell = {
url = "github:numtide/devshell";
inputs.utils.follows = "utils";
};
outputs = {
self,
nixpkgs,
utils,
devshell,
}:
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [devshell.overlay];
};
in rec {
packages.default = pkgs.buildGoModule {
name = "my-project";
src = self;
vendorSha256 = "";
# Inject the git version if you want
#ldflags = ''
# -X main.version=${if self ? rev then self.rev else "dirty"}
#'';
};
apps.default = utils.lib.mkApp {drv = packages.default;};
devShells.default =
pkgs.devshell.mkShell {packages = with pkgs; [go gopls];};
formatter = pkgs.alejandra;
});
}