Add golang template

This commit is contained in:
Sam W 2022-06-11 16:01:36 +01:00
parent 85999ed2cf
commit 114bfcbf80
3 changed files with 39 additions and 0 deletions

View File

@ -9,6 +9,10 @@
path = ./rust; path = ./rust;
description = "My preferred rust setup."; description = "My preferred rust setup.";
}; };
go = {
path = ./go;
description = "My preferred go setup.";
};
}; };
} // utils.lib.eachDefaultSystem (system: } // utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; }; let pkgs = import nixpkgs { inherit system; };

1
go/.envrc Normal file
View File

@ -0,0 +1 @@
use flake

34
go/flake.nix Normal file
View File

@ -0,0 +1,34 @@
{
description = "Another cool golang abhorration from samw";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.devshell = {
url = "github:numtide/devshell";
inputs.flake-utils.follows = "flake-utils";
};
outputs = { self, nixpkgs, flake-utils, devshell }:
flake-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; };
devShell =
pkgs.devshell.mkShell { packages = with pkgs; [ go gopls ]; };
});
}