feat: lab: +attic cache
This commit is contained in:
@@ -0,0 +1,67 @@
|
|||||||
|
{ ... }: {
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
cfg = config.hectic.services.attic;
|
||||||
|
environmentFile = "/var/lib/atticd/credentials.env";
|
||||||
|
in {
|
||||||
|
options.hectic.services.attic = {
|
||||||
|
enable = lib.mkEnableOption "Attic binary cache server";
|
||||||
|
|
||||||
|
hostName = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Public hostname used by clients to reach this Attic server.";
|
||||||
|
};
|
||||||
|
|
||||||
|
listenAddress = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
description = "Local address atticd binds to behind the reverse proxy.";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 8080;
|
||||||
|
description = "Local port atticd binds to behind the reverse proxy.";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.services.atticd-credentials = {
|
||||||
|
description = "Generate persistent atticd credentials";
|
||||||
|
before = [ "atticd.service" ];
|
||||||
|
wantedBy = [ "atticd.service" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
StateDirectory = "atticd";
|
||||||
|
UMask = "0077";
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
if [ -s ${environmentFile} ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -m 0700 -d /var/lib/atticd
|
||||||
|
secret="$(${lib.getExe pkgs.openssl} genrsa -traditional 4096 | ${pkgs.coreutils}/bin/base64 -w0)"
|
||||||
|
cat > ${environmentFile} <<EOF
|
||||||
|
ATTIC_SERVER_TOKEN_RS256_SECRET_BASE64="$secret"
|
||||||
|
EOF
|
||||||
|
chmod 0600 ${environmentFile}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.atticd = {
|
||||||
|
enable = true;
|
||||||
|
environmentFile = environmentFile;
|
||||||
|
settings = {
|
||||||
|
listen = "${cfg.listenAddress}:${toString cfg.port}";
|
||||||
|
allowed-hosts = [ cfg.hostName ];
|
||||||
|
api-endpoint = "https://${cfg.hostName}/";
|
||||||
|
compression.type = "zstd";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
domain,
|
||||||
|
...
|
||||||
|
}: { ... }: {
|
||||||
|
hectic.services.attic = {
|
||||||
|
enable = true;
|
||||||
|
hostName = "cache.${domain}";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx.virtualHosts."cache.${domain}" = {
|
||||||
|
enableACME = true;
|
||||||
|
forceSSL = true;
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://127.0.0.1:8080";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -52,9 +52,10 @@ in {
|
|||||||
|
|
||||||
inputs.hectic-landing.nixosModules.hectic-landing
|
inputs.hectic-landing.nixosModules.hectic-landing
|
||||||
|
|
||||||
|
(import ./attic.nix { inherit flake self inputs domain; })
|
||||||
(import ./containers.nix { inherit flake self inputs; })
|
(import ./containers.nix { inherit flake self inputs; })
|
||||||
(import ./mechabellum.nix { inherit flake self inputs domain sslOpts; })
|
(import ./mechabellum.nix { inherit flake self inputs domain; })
|
||||||
(import (./. + "/sentinèlla.nix") { inherit flake self inputs domain sslOpts; })
|
(import (./. + "/sentinèlla.nix") { inherit flake self inputs domain; })
|
||||||
];
|
];
|
||||||
|
|
||||||
services.hectic-landing = {
|
services.hectic-landing = {
|
||||||
@@ -205,8 +206,8 @@ in {
|
|||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
# NOTE(yukkop): virtualHosts.${domain} is owned by the hectic-landing module
|
# NOTE(yukkop): virtualHosts.${domain} is owned by the hectic-landing module
|
||||||
# (ACME-managed). See services.hectic-landing above.
|
virtualHosts."store.${domain}" = {
|
||||||
virtualHosts."store.${domain}" = sslOpts // {
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
root = "/var/www/store";
|
root = "/var/www/store";
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
@@ -215,7 +216,8 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
virtualHosts."snuff.${domain}" = sslOpts // {
|
virtualHosts."snuff.${domain}" = {
|
||||||
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
@@ -224,7 +226,8 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
virtualHosts."nrv.${domain}" = sslOpts // {
|
virtualHosts."nrv.${domain}" = {
|
||||||
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
@@ -233,7 +236,8 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
virtualHosts."yukkop.${domain}" = sslOpts // {
|
virtualHosts."yukkop.${domain}" = {
|
||||||
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
domain,
|
domain,
|
||||||
sslOpts,
|
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
pkgs,
|
pkgs,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
flake,
|
flake,
|
||||||
self,
|
self,
|
||||||
domain,
|
domain,
|
||||||
sslOpts,
|
|
||||||
...
|
...
|
||||||
}: { ... }: {
|
}: { ... }: {
|
||||||
hectic.services."sentinèlla" = {
|
hectic.services."sentinèlla" = {
|
||||||
@@ -17,7 +16,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
virtualHosts."probe.${domain}" = sslOpts // {
|
virtualHosts."probe.${domain}" = {
|
||||||
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:5988";
|
proxyPass = "http://127.0.0.1:5988";
|
||||||
|
|||||||
Reference in New Issue
Block a user