From 4ad3fe78f9807276d28fcedd9b2310421dced88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Thu, 12 Dec 2019 19:45:06 +0100 Subject: [PATCH] go: adds an option `extraGoPaths` PR #946 --- modules/programs/go.nix | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/programs/go.nix b/modules/programs/go.nix index 06c25c9b8..dd907591e 100644 --- a/modules/programs/go.nix +++ b/modules/programs/go.nix @@ -38,7 +38,27 @@ in type = with types; nullOr str; default = null; example = "go"; - description = "GOPATH relative to HOME"; + description = '' + Primary GOPATH relative to + HOME. 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 GOPATHs relative to HOME appended + after + ${goPathOpt}, + if that option is set. + ''; }; goBin = mkOption { @@ -66,7 +86,11 @@ in mapAttrsToList mkSrc cfg.packages; } (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) { home.sessionVariables.GOBIN = builtins.toPath "${config.home.homeDirectory}/${cfg.goBin}";