Introduced a new file `lib.nix` containing helper functions to streamline user package management and attributes for multi-user configurations. Updated various modules to utilize these functions, enhancing code maintainability and readability.
47 lines
1.2 KiB
Nix
47 lines
1.2 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 = let
|
|
userLib = import ../lib.nix { inherit lib; };
|
|
in userLib.mkUserAttrs config.my.toggleUsers.dev { inherit packages; };
|
|
})
|
|
];
|
|
}
|