diff --git a/bitte/default.nix b/bitte/default.nix new file mode 100644 index 0000000000..a5a2128a96 --- /dev/null +++ b/bitte/default.nix @@ -0,0 +1,10 @@ +{ docs, pkgs }: +let + staticSite = pkgs.callPackage ./static-site.nix { }; + playgroundStatic = pkgs.callPackage ./playground-static.nix { inherit staticSite; docs = docs.site; }; +in +{ + plutus-playground-client-entrypoint = playgroundStatic { + variant = "plutus"; + }; +} diff --git a/bitte/playground-static.nix b/bitte/playground-static.nix new file mode 100644 index 0000000000..f4e242ff06 --- /dev/null +++ b/bitte/playground-static.nix @@ -0,0 +1,11 @@ +{ staticSite, linkFarm, symlinkJoin, docs }: +let + shiftedDocs = linkFarm docs.name [{ name = "doc"; path = docs; }]; +in +{ variant }: staticSite { + root = (symlinkJoin { + name = "${variant}-playground-client-and-docs"; + paths = [ shiftedDocs ]; + }); + port-name = "${variant}_playground_client"; +} diff --git a/bitte/static-site.nix b/bitte/static-site.nix new file mode 100644 index 0000000000..275c92c4cb --- /dev/null +++ b/bitte/static-site.nix @@ -0,0 +1,28 @@ +# Needed variables: +# NOMAD_PORT_${port-name} +# NOMAD_IP_${port-name} +{ writeShellScriptBin, symlinkJoin, lib, writeText, lighttpd }: { root, port-name }: + +let + config = writeText "lighttpd.conf" '' + server.modules = ("mod_deflate") + server.document-root = "${root}" + server.port = env.NOMAD_PORT_${port-name} + server.bind = env.NOMAD_IP_${port-name} + index-file.names = ("index.html") + mimetype.assign = ( + ".css" => "text/css", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".html" => "text/html", + ".js" => "text/javascript", + ".svg" => "image/svg+xml", + ) + deflate.cache-dir = "/tmp" + deflate.mimetypes = ("text/plain", "text/html", "text/css") + server.upload-dirs = ("/tmp") + ''; +in +writeShellScriptBin "entrypoint" '' + exec -a lighttpd ${lighttpd}/bin/lighttpd -f ${config} -D +'' diff --git a/default.nix b/default.nix index 22de98c8bb..edc4c6b82c 100644 --- a/default.nix +++ b/default.nix @@ -71,4 +71,7 @@ rec { devcontainer = import ./nix/devcontainer/plutus-devcontainer.nix { inherit pkgs plutus-apps; }; build-and-push-devcontainer-script = import ./nix/devcontainer/deploy/default.nix { inherit pkgs plutus-apps; }; + + # Packages needed for the bitte deployment + bitte-packages = import ./bitte { inherit docs pkgs; }; }