From e841187b3f9a313a0f8f930a3d3f8d8409e2c04f Mon Sep 17 00:00:00 2001 From: David Wolff Date: Mon, 15 Sep 2025 18:56:30 +0200 Subject: [PATCH] lldap: remove runtime reliance on third party CDNs External assets for the frontend are included in the package instead of being fetched from third party CDNs by clients. This is consistent with upstream's docker image and results in better offline availability and privacy. --- pkgs/by-name/ll/lldap/package.nix | 37 ++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ll/lldap/package.nix b/pkgs/by-name/ll/lldap/package.nix index becae0dea4a3..e14a5d130be4 100644 --- a/pkgs/by-name/ll/lldap/package.nix +++ b/pkgs/by-name/ll/lldap/package.nix @@ -10,6 +10,10 @@ wasm-bindgen-cli_0_2_100, wasm-pack, which, + runCommand, + cacert, + curl, + staticAssetsHash ? "sha256-xVbHD9s3ofbtHCDvjYwmsWXDEJ9z9vRxQDRR6pW6rt8=", }: let @@ -29,7 +33,35 @@ let cargoHash = "sha256-SO7+HiiXNB/KF3fjzSMeiTPjRQq/unEfsnplx4kZv9c="; }; + staticAssets = + src: + runCommand "${commonDerivationAttrs.pname}-static-assets" + { + outputHash = staticAssetsHash; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + + inherit src; + + nativeBuildInputs = [ + curl + ]; + + env.SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + } + '' + mkdir $out + mkdir $out/fonts + for file in $(cat ${src}/app/static/libraries.txt); do + curl $file --location --remote-name --output-dir $out + done + for file in $(cat ${src}/app/static/fonts/fonts.txt); do + curl $file --location --remote-name --output-dir $out/fonts + done + ''; + frontend = rustPlatform.buildRustPackage ( + finalAttrs: commonDerivationAttrs // { pname = commonDerivationAttrs.pname + "-frontend"; @@ -49,7 +81,10 @@ let installPhase = '' mkdir -p $out - cp -R app/{index.html,pkg,static} $out/ + cp -R app/{pkg,static} $out/ + cp app/index_local.html $out/index.html + cp -R ${staticAssets finalAttrs.src}/* $out/static + rm $out/static/libraries.txt $out/static/fonts/fonts.txt ''; doCheck = false;