Skip to content

Commit c77b5fb

Browse files
committed
book/admin-guide: Add some docs on the NixOS module
1 parent a42953b commit c77b5fb

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [Tutorial](./tutorial.md)
55
- [User Guide](./user-guide/README.md)
66
- [Admin Guide](./admin-guide/README.md)
7+
- [Deploying to NixOS](./admin-guide/deployment/nixos.md)
78
- [Chunking](./admin-guide/chunking.md)
89
- [FAQs](./faqs.md)
910
- [Reference](./reference/README.md)

book/src/admin-guide/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# Admin Guide
22

33
> This section is under construction.
4+
5+
This section describes how to set up and administer an Attic Server.
6+
For a quick start, read the [Tutorial](../tutorial.md).
7+
8+
- **[Deploying to NixOS](./deployment/nixos.md)** - Deploying to a NixOS machine
9+
- **[Chunking](./chunking.md)** - Configuring Content-Defined Chunking data deduplication in Attic
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Deploying to NixOS
2+
3+
Attic provides [a NixOS module](https://github.com/zhaofengli/attic/blob/main/nixos/atticd.nix) that allows you to deploy the Attic Server on a NixOS machine.
4+
5+
## Prerequisites
6+
7+
1. A machine running NixOS
8+
1. _(Optional)_ A dedicated bucket on S3 or a S3-compatible storage service
9+
- You can either [set up Minio](https://search.nixos.org/options?query=services.minio) or use a hosted service like [Backblaze B2](https://www.backblaze.com/b2/docs) and [Cloudflare R2](https://developers.cloudflare.com/r2).
10+
1. _(Optional)_ A PostgreSQL database
11+
12+
## Generating the Credentials File
13+
14+
The HS256 JWT secret can be generated with the `openssl` utility:
15+
16+
```bash
17+
openssl rand 64 | base64 -w0
18+
```
19+
20+
Create a file on the server containing the following contents:
21+
22+
```
23+
ATTIC_SERVER_TOKEN_HS256_SECRET_BASE64="output from openssl"
24+
```
25+
26+
Ensure the file is only accessible by root.
27+
28+
## Importing the Module
29+
30+
You can import the module in one of two ways:
31+
32+
- Ad-hoc: Import the `nixos/atticd.nix` from [the repository](https://github.com/zhaofengli/attic).
33+
- Flakes: Add `github:zhaofengli/attic` as an input, then import `attic.nixosModules.atticd`.
34+
35+
## Configuration
36+
37+
> Note: These options are subject to change.
38+
39+
```nix
40+
{
41+
services.atticd = {
42+
enable = true;
43+
44+
# Replace with absolute path to your credentials file
45+
credentialsFile = "/etc/atticd.env";
46+
47+
settings = {
48+
listen = "[::]:8080";
49+
50+
# Data chunking
51+
#
52+
# Warning: If you change any of the values here, it will be
53+
# difficult to reuse existing chunks for newly-uploaded NARs
54+
# since the cutpoints will be different. As a result, the
55+
# deduplication ratio will suffer for a while after the change.
56+
chunking = {
57+
# The minimum NAR size to trigger chunking
58+
#
59+
# If 0, chunking is disabled entirely for newly-uploaded NARs.
60+
# If 1, all NARs are chunked.
61+
nar-size-threshold = 64 * 1024; # 64 KiB
62+
63+
# The preferred minimum size of a chunk, in bytes
64+
min-size = 16 * 1024; # 16 KiB
65+
66+
# The preferred average size of a chunk, in bytes
67+
avg-size = 64 * 1024; # 64 KiB
68+
69+
# The preferred maximum size of a chunk, in bytes
70+
max-size = 256 * 1024; # 256 KiB
71+
};
72+
};
73+
};
74+
}
75+
```
76+
77+
After the new configuration is deployed, the Attic Server will be accessible on port 8080.
78+
It's highly recommended to place it behind a reverse proxy like [NGINX](https://nixos.wiki/wiki/Nginx) to provide HTTPS.
79+
80+
## Operations
81+
82+
The NixOS module installs the `atticd-atticadm` wrapper which runs the `atticadm` command as the `atticd` user.
83+
Use this command to [generate new tokens](../../reference/atticadm-cli.md#atticadm-make-token) to be distributed to users.

0 commit comments

Comments
 (0)