1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

go: adds an option extraGoPaths

PR #946
This commit is contained in:
Vojtěch Káně 2019-12-12 19:45:06 +01:00 committed by Robert Helgesson
parent 297ed97166
commit 4ad3fe78f9
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -38,7 +38,27 @@ in
type = with types; nullOr str; type = with types; nullOr str;
default = null; default = null;
example = "go"; example = "go";
description = "GOPATH relative to HOME"; description = ''
Primary <envar>GOPATH</envar> relative to
<envar>HOME</envar>. It will be exported first and therefore
used by default by the Go tooling.
'';
};
extraGoPaths = mkOption {
type = types.listOf types.str;
default = [];
example = [ "extraGoPath1" "extraGoPath2" ];
description =
let
goPathOpt = "programs.go.goPath";
in
''
Extra <envar>GOPATH</envar>s relative to <envar>HOME</envar> appended
after
<varname><link linkend="opt-${goPathOpt}">${goPathOpt}</link></varname>,
if that option is set.
'';
}; };
goBin = mkOption { goBin = mkOption {
@ -66,7 +86,11 @@ in
mapAttrsToList mkSrc cfg.packages; mapAttrsToList mkSrc cfg.packages;
} }
(mkIf (cfg.goPath != null) { (mkIf (cfg.goPath != null) {
home.sessionVariables.GOPATH = builtins.toPath "${config.home.homeDirectory}/${cfg.goPath}"; home.sessionVariables.GOPATH =
concatStringsSep ":"
(map builtins.toPath
(map (path: "${config.home.homeDirectory}/${path}")
([cfg.goPath] ++ cfg.extraGoPaths)));
}) })
(mkIf (cfg.goBin != null) { (mkIf (cfg.goBin != null) {
home.sessionVariables.GOBIN = builtins.toPath "${config.home.homeDirectory}/${cfg.goBin}"; home.sessionVariables.GOBIN = builtins.toPath "${config.home.homeDirectory}/${cfg.goBin}";