nix-cfg/hosts/laptop/akkoma/akkoma-static.nix

30 lines
1.2 KiB
Nix
Raw Normal View History

2024-02-18 10:48:52 +01:00
{ 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" ];
};
}