1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 19:29:47 +01:00

go: add module

This commit is contained in:
Roman Volosatovs 2018-08-18 16:13:33 +02:00 committed by Robert Helgesson
parent 3f34bf4465
commit 0635423e73
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 82 additions and 0 deletions

View file

@ -800,6 +800,13 @@ in
A new module is available: 'programs.noti'. A new module is available: 'programs.noti'.
''; '';
} }
{
time = "2018-09-20T22:10:45+00:00";
message = ''
A new module is available: 'programs.go'.
'';
}
]; ];
}; };
} }

View file

@ -38,6 +38,7 @@ let
./programs/fzf.nix ./programs/fzf.nix
./programs/git.nix ./programs/git.nix
./programs/gnome-terminal.nix ./programs/gnome-terminal.nix
./programs/go.nix
./programs/home-manager.nix ./programs/home-manager.nix
./programs/htop.nix ./programs/htop.nix
./programs/info.nix ./programs/info.nix

74
modules/programs/go.nix Normal file
View file

@ -0,0 +1,74 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.go;
in
{
meta.maintainers = [ maintainers.rvolosatovs ];
options = {
programs.go = {
enable = mkEnableOption "Go";
package = mkOption {
type = types.package;
default = pkgs.go;
defaultText = "pkgs.go";
description = "The Go package to use.";
};
packages = mkOption {
type = with types; attrsOf path;
default = {};
example = literalExample ''
{
"golang.org/x/time/rate" = builtins.fetchGit "https://go.googlesource.com/text";
}
'';
description = "Packages to add to GOPATH.";
};
goPath = mkOption {
type = with types; nullOr str;
default = null;
example = "go";
description = "GOPATH relative to HOME";
};
goBin = mkOption {
type = with types; nullOr str;
default = null;
example = ".local/bin.go";
description = "GOBIN relative to HOME";
};
};
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = [ cfg.package ];
home.file =
let
goPath = if cfg.goPath != null then cfg.goPath else "go";
mkSrc = n: v: {
target = "${goPath}/src/${n}";
source = v;
};
in
mapAttrsToList mkSrc cfg.packages;
}
(mkIf (cfg.goPath != null) {
home.sessionVariables.GOPATH = builtins.toPath "${config.home.homeDirectory}/${cfg.goPath}";
})
(mkIf (cfg.goBin != null) {
home.sessionVariables.GOBIN = builtins.toPath "${config.home.homeDirectory}/${cfg.goBin}";
})
]);
}