blob: 0eb476d6746071e5c6d5a5702e8296a513486338 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
{ lib, pkgs, config, ... }:
let
cfg = config.myServices.websites.tools.assets;
assets_urls = lib.mapAttrs (k: v: pkgs.fetchurl v) config.myEnv.tools.assets;
assets = pkgs.runCommand "assets" {} (''
mkdir -p $out
cp -a ${./static}/* $out/
'' + builtins.concatStringsSep "\n"
(lib.mapAttrsToList (k: v: ''
install -D -m644 -T ${v} $out/${k}
'') assets_urls));
in
{
options.myServices.websites.tools.assets = {
enable = lib.mkEnableOption "Enable assets website";
};
config = lib.mkIf cfg.enable {
services.websites.env.tools.vhostConfs.assets = {
certName = "eldiron";
addToCerts = true;
hosts = [ "assets.immae.eu" ];
root = assets;
extraConfig = [
''
Use Apaxy "${assets}" "title"
<Directory "${assets}">
Options Indexes FollowSymlinks
AllowOverride None
Require all granted
Header always set Last-Modified "Tue, 01 Jan 2020 00:00:00 GMT"
Header always set Cache-Control "public, max-age=31536000, immutable"
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Expose-Headers "*"
</Directory>
''
];
};
};
}
|