cache.nixos.org: provide index.html

This commit is contained in:
makefu 2018-12-03 09:20:14 +01:00
parent b8db729338
commit 5782a4de2e
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
2 changed files with 16 additions and 12 deletions

View File

@ -1,4 +1,4 @@
{lib, ... }:
{ pkgs, lib, ... }:
with lib;
let
domain = "cache.nsupdate.info";
@ -17,9 +17,13 @@ in {
};
krebs.cachecache = {
enable = true;
enableSSL = false; # disable letsencrypt for testing
enableSSL = true; # disable letsencrypt for testing
cacheDir = "/var/cache/nix-cache-cache";
maxSize = "10g";
indexFile = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/krebs/35c3-nixos-cache/master/index.html";
sha256 = "0n9lji4rpi2wpfik3dvl92mmpfrywyp33iwsw7d8qmykk7l0hfp8";
};
# assumes that the domain is reachable from the internet
virtualHost = domain;

View File

@ -1,4 +1,4 @@
{ config, lib, ... }:
{ pkgs, config, lib, ... }:
# fork of https://gist.github.com/rycee/f495fc6cc4130f155e8b670609a1e57b
@ -59,15 +59,6 @@ in
'';
};
# webRoot = mkOption {
# type = types.str;
# default = "/";
# description = ''
# Directory on virtual host that serves the cache. Must end in
# <literal>/</literal>.
# '';
# };
resolver = mkOption {
type = types.str;
description = "Address of DNS resolver.";
@ -82,6 +73,13 @@ in
Where nginx should store cached data.
'';
};
indexFile = mkOption {
type = types.path;
default = pkgs.writeText "myindex" "<html>hello world</html>";
description = ''
Path to index.html file.
'';
};
maxSize = mkOption {
type = types.str;
@ -98,6 +96,7 @@ in
systemd.services.nginx.preStart = ''
mkdir -p ${cfg.cacheDir} /srv/www/nix-cache-cache
chmod 700 ${cfg.cacheDir} /srv/www/nix-cache-cache
ln -fs ${cfg.indexFile} /srv/www/nix-cache-cache/index.html
chown ${nginxCfg.user}:${nginxCfg.group} \
${cfg.cacheDir} /srv/www/nix-cache-cache
'';
@ -143,6 +142,7 @@ in
locations."/" =
{
root = "/srv/www/nix-cache-cache";
index = "index.html";
extraConfig = ''
expires max;
add_header Cache-Control $nix_cache_cache_header always;