feat(binary-cache): Add some hints on how to configure the cache
All checks were successful
build configuration / build_web02 (push) Successful in 1m9s
build configuration / build_vault01 (push) Successful in 1m10s
build configuration / build_storage01 (push) Successful in 1m14s
build configuration / build_rescue01 (push) Successful in 1m16s
build configuration / build_compute01 (push) Successful in 1m20s
build configuration / build_web01 (push) Successful in 1m40s
lint / check (push) Successful in 25s
build configuration / build_geo01 (push) Successful in 1m3s
build configuration / build_geo02 (push) Successful in 1m5s
build configuration / build_bridge01 (push) Successful in 1m16s
build configuration / push_to_cache_vault01 (push) Successful in 1m21s
build configuration / push_to_cache_web02 (push) Successful in 1m16s
build configuration / push_to_cache_storage01 (push) Successful in 1m21s
build configuration / push_to_cache_rescue01 (push) Successful in 1m17s
build configuration / push_to_cache_geo01 (push) Successful in 1m10s
build configuration / push_to_cache_compute01 (push) Successful in 1m44s
build configuration / push_to_cache_geo02 (push) Successful in 1m7s
build configuration / push_to_cache_bridge01 (push) Successful in 1m15s
build configuration / push_to_cache_web01 (push) Successful in 1m52s

This commit is contained in:
sinavir 2024-10-06 23:54:00 +02:00
parent e4fc6a0d98
commit bdf0e4cf7a
5 changed files with 52 additions and 9 deletions

View file

@ -9,6 +9,23 @@ You're expected to read this document before commiting to the repo.
Some documentation for the development tools are provided in the aforementioned file. Some documentation for the development tools are provided in the aforementioned file.
# Using the binary cache
Add the following module to your configuration (and pin this repo using your favorite tool: npins, lon, etc...):
```
{ lib, ... }:
let
dgnum-infra = PINNED_PATH_TO_INFRA;
in {
nix.settings = (import dgnum-infra).mkCacheSettings {
caches = [
"infra"
];
};
}
```
# Adding a new machine # Adding a new machine
The first step is to create a minimal viable NixOS host, using tha means necessary. The first step is to create a minimal viable NixOS host, using tha means necessary.

View file

@ -76,6 +76,8 @@ in
dns = import ./meta/dns.nix; dns = import ./meta/dns.nix;
mkCacheSettings = import ./machines/storage01/tvix-store/cache-settings.nix;
shells = { shells = {
default = pkgs.mkShell { default = pkgs.mkShell {
name = "dgnum-infra"; name = "dgnum-infra";

View file

@ -0,0 +1,14 @@
let
cache-info = {
infra = {
public-key = "infra.tvix-store.dgnum.eu-1:8CAY64o3rKjyw2uA5mzr/aTzstnc+Uj4g8OC6ClG1m8=";
url = "https://tvix-store.dgnum.eu/infra";
};
};
in
{ caches }:
{
trusted-substituters = builtins.map (cache: cache-info.${cache}.url) caches;
trusted-public-keys = builtins.map (cache: cache-info.${cache}.public-key) caches;
}

View file

@ -1,9 +1,13 @@
{ pkgs, config, ... }: { pkgs, config, ... }:
let let
settingsFormat = pkgs.formats.toml { };
dataDir = "/data/slow/tvix-store";
# How to add a cache:
# - Add the relevant services (likely only a pathinfoservice) to the
# composition config (store-config.composition).
# - Add an endpoint (store-config.endpoints).
# - Append a proxy configuration to nginx in order to make the store
# accessible.
# - Update cache-info.nix so users can add the cache to their configuration
store-config = { store-config = {
composition = { composition = {
blobservices.default = { blobservices.default = {
@ -54,6 +58,13 @@ let
}; };
}; };
}; };
settingsFormat = pkgs.formats.toml { };
webHost = "tvix-store.dgnum.eu";
dataDir = "/data/slow/tvix-store";
systemdHardening = { systemdHardening = {
PrivateDevices = true; PrivateDevices = true;
PrivateTmp = true; PrivateTmp = true;
@ -70,10 +81,12 @@ let
RuntimeDirectoryMode = "0750"; RuntimeDirectoryMode = "0750";
StateDirectoryMode = "0750"; StateDirectoryMode = "0750";
}; };
toml = { toml = {
composition = settingsFormat.generate "composition.toml" store-config.composition; composition = settingsFormat.generate "composition.toml" store-config.composition;
endpoints = settingsFormat.generate "endpoints.toml" store-config.endpoints; endpoints = settingsFormat.generate "endpoints.toml" store-config.endpoints;
}; };
package = pkgs.callPackage ./package { }; package = pkgs.callPackage ./package { };
in in
{ {
@ -83,7 +96,7 @@ in
"nginx" "nginx"
]; ];
services.nginx.virtualHosts."tvix-store.dgnum.eu" = { services.nginx.virtualHosts.${webHost} = {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
locations = { locations = {
@ -105,14 +118,12 @@ in
auth_basic_user_file ${config.age.secrets."nginx-tvix-store-password-ci".path}; auth_basic_user_file ${config.age.secrets."nginx-tvix-store-password-ci".path};
''; '';
}; };
"/.well-known/nix-signing-keys/" = {
alias = "${./pubkeys}/";
extraConfig = "autoindex on;";
};
}; };
}; };
# TODO add tvix-store cli here # TODO add tvix-store cli here
# environment.systemPackages = [ ]; # environment.systemPackages = [ ];
users.users.tvix-store = { users.users.tvix-store = {
isSystemUser = true; isSystemUser = true;
group = "tvix-store"; group = "tvix-store";

View file

@ -1 +0,0 @@
infra.tvix-store.dgnum.eu-1:8CAY64o3rKjyw2uA5mzr/aTzstnc+Uj4g8OC6ClG1m8=