mirror of
https://git.lgmrszd.xyz/Lgmrszd/nix-cfg.git
synced 2024-11-22 19:27:49 +01:00
30 lines
1.2 KiB
Nix
30 lines
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" ];
|
||
|
};
|
||
|
}
|