2023-11-04 02:46:35 +01:00
# Athens {#module-athens}
*Source:* {file}`modules/services/development/athens.nix`
*Upstream documentation:* < https: / / docs . gomods . io / >
[Athens ](https://github.com/gomods/athens )
is a Go module datastore and proxy
The main goal of Athens is providing a Go proxy (`$GOPROXY` ) in regions without access to `https://proxy.golang.org` or to
improve the speed of Go module downloads for CI/CD systems.
## Configuring {#module-services-development-athens-configuring}
A complete list of options for the Athens module may be found
[here ](#opt-services.athens.enable ).
## Basic usage for a caching proxy configuration {#opt-services-development-athens-caching-proxy}
A very basic configuration for Athens that acts as a caching and forwarding HTTP proxy is:
2024-03-27 17:33:27 +01:00
```nix
2023-11-04 02:46:35 +01:00
{
services.athens = {
enable = true;
};
}
```
If you want to prevent Athens from writing to disk, you can instead configure it to cache modules only in memory:
2024-03-27 17:33:27 +01:00
```nix
2023-11-04 02:46:35 +01:00
{
services.athens = {
enable = true;
storageType = "memory";
};
}
```
2024-11-08 15:51:39 +01:00
To use the local proxy in Go builds (outside of `nix` ), you can set the proxy as environment variable:
2023-11-04 02:46:35 +01:00
2024-03-27 17:33:27 +01:00
```nix
2023-11-04 02:46:35 +01:00
{
environment.variables = {
2024-03-27 19:10:27 +01:00
GOPROXY = "http://localhost:3000";
2023-11-04 02:46:35 +01:00
};
}
```
2024-11-08 15:51:39 +01:00
To also use the local proxy for Go builds happening in `nix` (with `buildGoModule` ), the nix daemon can be configured to pass the GOPROXY environment variable to the `goModules` fixed-output derivation.
This can either be done via the nix-daemon systemd unit:
```nix
{
systemd.services.nix-daemon.environment.GOPROXY = "http://localhost:3000";
}
```
or via the [impure-env experimental feature ](https://nix.dev/manual/nix/2.24/command-ref/conf-file#conf-impure-env ):
```nix
{
nix.settings.experimental-features = [ "configurable-impure-env" ];
nix.settings.impure-env = "GOPROXY=http://localhost:3000";
}
```