nixos-config/config/services/shitalloverme.nix

46 lines
1.2 KiB
Nix
Raw Normal View History

2022-12-28 15:01:03 +00:00
{
system,
pkgs,
...
}: let
2023-06-13 05:46:23 +00:00
input = "${pkgs.lotte-art}/2022-12-27-rexyi-scatych.jxl";
2022-12-28 15:01:03 +00:00
sizes = [1 2 4 8 16 32 64 128 256 512 1024 2000];
formats = ["jxl" "avif" "heic" "webp" "jpeg" "png"];
mkImage = format: size: let
pkg = pkgs.stdenvNoCC.mkDerivation {
src = pkgs.emptyDirectory;
name = "${toString size}.${format}";
nativeBuildInputs = with pkgs; [imagemagick];
buildPhase = ''
mkdir $out
convert ${input} -resize ${toString size}x${toString size} $out/${toString size}.${format}
'';
installPhase = "true";
};
in "${pkg}/${toString size}.${format}";
files = builtins.concatMap (format: map (mkImage format) sizes) formats;
shitalloverme = pkgs.stdenvNoCC.mkDerivation {
src = pkgs.emptyDirectory;
name = "shitallover.me";
buildPhase = "true";
installPhase = ''
mkdir $out
ln -sv ${../../extra/shitalloverme.html} $out/index.html
for f in ${toString files}; do
ln -sv $f $out
done
'';
};
in {
services.caddy.virtualHosts."shitallover.me" = {
useACMEHost = "shitallover.me";
2022-12-30 13:03:57 +00:00
logFormat = pkgs.lib.mkForce "";
2022-12-28 15:01:03 +00:00
extraConfig = ''
import baseConfig
2022-12-28 15:49:40 +00:00
root * ${shitalloverme}
2022-12-28 15:01:03 +00:00
file_server
'';
};
}