Garage
Garage is an open-source, self-hostable S3 store, for geodistributed stores.
It is documented in the NixOS manual.
Setup
You have to explicitly set the package option. You can choose between the garage_1 and garage_2 packages.
For a minimal setup you need to configure rpc_bind_addr, s3_api.s3_region, replication_factor and rpc_secret_file.
The Garage systemd service has DynamicUser configured, which prevents you from setting the owner property of the secret.
Adding the secret without it like this:
{ config, ... }:
{
sops.secrets."garage/rpc_secret" = { };
services.garage.settings.rpc_secret_file = config.sops.secrets."garage/rpc_secret".path;
}
Results in: Error: Failed to read secret file /run/secrets/garage/rpc_secret: Permission denied (os error 13) You can use systemd LoadCredential to make it accessible for the dynamic user running the service:
{ config, ... }:
{
sops.secrets."garage/rpc_secret" = { };
services.garage.settings.rpc_secret_file = "/run/credentials/garage.service/rpc_secret";
systemd.services.garage.serviceConfig.LoadCredential =
"rpc_secret:${config.sops.secrets."garage/rpc_secret".path}";
}
However this results in another error in the Garage service:
2026-11-24T00:20:43.071157Z INFO garage::server: Loading configuration from /etc/garage.toml...
Error: File /run/credentials/garage.service/rpc_secret is world-readable! (mode: 0100440, expected 0600)
Refusing to start until this is fixed, or environment variable GARAGE_ALLOW_WORLD_READABLE_SECRETS is set to true.
This is because garage expects the file to have a umask of 600, not 440. To accept this umask (which is secure, as you can see in the following codeblock) you can set the allow_world_readable_secrets setting.
# systemctl start garage; getfacl /run/credentials/garage.service/rpc_secret
getfacl: Removing leading '/' from absolute path names
# file: run/credentials/garage.service/rpc_secret
# owner: root
# group: root
user::r--
user:garage:r--
group::---
mask::r--
other::---
The final configuration looks like this:
{ config, pkgs, ... }:
{
sops.secrets."garage/rpc_secret" = { };
services.garage = {
enable = true;
package = pkgs.garage_2;
settings = {
rpc_bind_addr = "[::1]:3901";
replication_factor = 1;
s3_api = {
s3_region = "garage";
api_bind_addr = "[::]:3900";
};
rpc_secret_file = "/run/credentials/garage.service/rpc_secret";
allow_world_readable_secrets = true;
};
};
systemd.services.garage.serviceConfig.LoadCredential =
"rpc_secret:${config.sops.secrets."garage/rpc_secret".path}";
networking.firewall.allowedTCPPorts = [ 3900 ];
}
You can check the status of the garage server
# sudo garage status
==== HEALTHY NODES ====
ID Hostname Address Tags Zone Capacity DataAvail ResyncQueue Version
8b03eb0fff755598 app 192.0.2.10:3901 NO ROLE ASSIGNED 0 cargo:2.5.0
Next you can create a layout and s3 bucket:
sudo garage layout assign -z dc1 -c 1G 8b03eb0fff755598
sudo garage layout show
sudo garage layout apply --version 1
sudo garage bucket create garage-test-one
sudo garage key create garage-test-one
sudo garage bucket allow --read --write --owner garage-test-one --key garage-test-one
And test it for example using aws cli:
export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
export AWS_DEFAULT_REGION='garage'
aws --endpoint-url http://192.0.2.10:3900 s3 ls
echo "Test" > /tmp/test.txt
aws --endpoint-url http://192.0.2.10:3900 s3 cp /tmp/test.txt s3://garage-test-one/
aws --endpoint-url http://192.0.2.10:3900 s3 ls s3://garage-test-one/
aws --endpoint-url http://192.0.2.10:3900 s3 cp s3://garage-test-one/ test.txt
cat test.txt
aws --endpoint-url http://192.0.2.10:3900 s3 rm s3://garage-test-one/test.txt
Please note that this uses HTTP, which transmits data in clear text and is insecure. You want to configure a reverse proxy (e.g. nginx) which handels tls termination:
{
services = {
garage.settings.s3_api.api_bind_addr = "[::1]:3900";
nginx = {
enable = true;
virtualHosts."s3.example.com" = {
locations."/".proxyPass = "http://[::1]:3900";
serverName = "s3.example.com";
forceSSL = true;
enableACME = true; # use ACME HTTP-01 challenge
};
};
};
security.acme.acceptTerms = true;
networking.firewall.allowedTCPPorts = [ 80 443 ];
}