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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user