From 7635bf6ff4fd3328c68c61868342793c2a83d68a Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 16 Oct 2021 20:24:13 +0200 Subject: [PATCH] VEGAS: provide a Nix binary cache --- hosts/VEGAS/services/nix/binary-cache.nix | 18 ++++++++++++++++++ hosts/VEGAS/system.nix | 1 + 2 files changed, 19 insertions(+) create mode 100644 hosts/VEGAS/services/nix/binary-cache.nix diff --git a/hosts/VEGAS/services/nix/binary-cache.nix b/hosts/VEGAS/services/nix/binary-cache.nix new file mode 100644 index 0000000..48c3a77 --- /dev/null +++ b/hosts/VEGAS/services/nix/binary-cache.nix @@ -0,0 +1,18 @@ +{ config, tools, ... }: +with tools.nginx; +let + addrSplit' = builtins.split ":" config.services.minio.listenAddress; + addrSplit = builtins.filter builtins.isString addrSplit'; + host' = builtins.head addrSplit; + host = if host' == "" then "127.0.0.1" else host'; + port = builtins.head (builtins.tail addrSplit); +in +{ + services.nginx.virtualHosts."cache.${tools.meta.domain}" = vhosts.basic // { + locations = { + "= /".return = "302 /404"; + "/".proxyPass = "http://${host}:${port}/nix-store$request_uri"; + "/nix/store".proxyPass = "http://127.0.0.1:${builtins.toString config.services.nar-serve.port}"; + }; + }; +} diff --git a/hosts/VEGAS/system.nix b/hosts/VEGAS/system.nix index 06b6b35..56e0acd 100644 --- a/hosts/VEGAS/system.nix +++ b/hosts/VEGAS/system.nix @@ -29,6 +29,7 @@ ./services/nfs ./services/mail ./services/matrix + ./services/nix/binary-cache.nix ./services/object-storage ./services/warehouse ./services/websites