Unverified Commit 55b9d193 authored by Herwig Hochleitner's avatar Herwig Hochleitner Committed by GitHub
Browse files

lldap: remove runtime reliance on third party CDNs (#443964)

parents 42d038fc e841187b
Loading
Loading
Loading
Loading
+36 −1
Original line number Diff line number Diff line
@@ -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;