NixOS/modules/dev/go.nix

46 lines
1.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
packages = builtins.attrValues {
inherit (pkgs)
go # Go compiler and core toolchain
gocode-gomod # Code completion for Go (modern fork of gocode)
gotools # Contains godoc, gorename, goimports, etc.
gore # Go REPL
gotests # Generate Go tests from function signatures
gomodifytags # Struct tag manipulation
golangci-lint # Linter aggregation
;
};
GOPATH = "\${XDG_DATA_HOME}/go";
in
{
options = {
my.dev.go.enable = lib.mkEnableOption "Install Go tooling globally";
devShells.go = lib.mkOption {
type = lib.types.package;
default = pkgs.mkShell {
inherit packages GOPATH;
name = "go-dev-shell";
shellHook = ''
echo "🐹 Go dev environment"
'';
};
description = "Go development shell with Emacs tooling, REPL, formatter, and linter";
};
};
config = lib.mkMerge [
{
environment.variables = { inherit GOPATH; };
}
(lib.mkIf config.my.dev.go.enable {
users.users.jawz = { inherit packages; };
})
];
}