nix-cfg/hosts/vps1/akkoma/akkoma-static.nix
2024-02-23 01:52:10 +03:00

30 lines
No EOL
1.2 KiB
Nix

{ pkgs, config, lib, ... }:
let
imperativeStaticPath = "/data/akkoma/static_i";
declarativeStaticPath = "/data/akkoma/static_d";
mergedStaticPath = "/data/akkoma/static";
declarativeStaticFiles = let cfg = config.services.akkoma; in with lib; pkgs.runCommandLocal "declarative-akkoma-static" { } ''
${concatStringsSep "\n" (mapAttrsToList (key: val: ''
mkdir -p $out/frontends/${escapeShellArg val.name}/
ln -s ${escapeShellArg val.package} $out/frontends/${escapeShellArg val.name}/${escapeShellArg val.ref}
'') cfg.frontends)}
${optionalString (cfg.extraStatic != null)
(concatStringsSep "\n" (mapAttrsToList (key: val: ''
mkdir -p "$out/$(dirname ${escapeShellArg key})"
ln -s ${escapeShellArg val} $out/${escapeShellArg key}
'') cfg.extraStatic))}
'';
in
{
environment.systemPackages = with pkgs; [ mergerfs ];
systemd.tmpfiles.rules = [
"d ${imperativeStaticPath} 700 akkoma akkoma -"
"L+ ${declarativeStaticPath} - - - - ${toString declarativeStaticFiles}"
];
fileSystems."${mergedStaticPath}" = {
fsType = "fuse.mergerfs";
device = "${imperativeStaticPath}:${declarativeStaticPath}";
options = [ "cache.files=off" "dropcacheonclose=true" "category.create=epff" ];
};
}