From 698b613054ca00403054d169c5a80e8ece5d78c3 Mon Sep 17 00:00:00 2001 From: Matthew Kenigsberg Date: Wed, 16 Oct 2024 11:19:03 -0600 Subject: [PATCH] Add nginx environment Add environment that starts an nginx server with a "Hello World!" index.html --- nginx/.flox/.gitignore | 4 + nginx/.flox/env.json | 4 + nginx/.flox/env/manifest.lock | 160 ++++++++++++++++++++++++++++++++++ nginx/.flox/env/manifest.toml | 66 ++++++++++++++ nginx/test.sh | 3 + 5 files changed, 237 insertions(+) create mode 100644 nginx/.flox/.gitignore create mode 100644 nginx/.flox/env.json create mode 100644 nginx/.flox/env/manifest.lock create mode 100644 nginx/.flox/env/manifest.toml create mode 100644 nginx/test.sh diff --git a/nginx/.flox/.gitignore b/nginx/.flox/.gitignore new file mode 100644 index 0000000..15d71a1 --- /dev/null +++ b/nginx/.flox/.gitignore @@ -0,0 +1,4 @@ +run/ +cache/ +lib/ +log/ diff --git a/nginx/.flox/env.json b/nginx/.flox/env.json new file mode 100644 index 0000000..54e04ce --- /dev/null +++ b/nginx/.flox/env.json @@ -0,0 +1,4 @@ +{ + "name": "nginx", + "version": 1 +} \ No newline at end of file diff --git a/nginx/.flox/env/manifest.lock b/nginx/.flox/env/manifest.lock new file mode 100644 index 0000000..40c511e --- /dev/null +++ b/nginx/.flox/env/manifest.lock @@ -0,0 +1,160 @@ +{ + "lockfile-version": 1, + "manifest": { + "version": 1, + "install": { + "nginx": { + "pkg-path": "nginx" + } + }, + "hook": { + "on-activate": "export NGINX_DIR=\"$FLOX_ENV_CACHE/nginx\"\nexport NGINX_CONFIG=\"$NGINX_DIR/nginx.conf\"\nexport NGINX_ROOT=\"$NGINX_DIR/www\"\n\nif [ ! -e \"$NGINX_CONFIG\" ]; then\n mkdir -p \"$NGINX_DIR\"\n cat < \"$NGINX_CONFIG\"\nlock_file $NGINX_DIR/nginx.lock;\npid $NGINX_DIR/nginx.pid;\nevents {\n}\nhttp {\n server {\n listen 8080;\n root $NGINX_ROOT;\n \n location / {\n }\n\n access_log $NGINX_DIR/access.log;\n }\n}\nEOF\n\nfi\n\nif [ ! -e \"$NGINX_ROOT/index.html\" ]; then\n mkdir -p \"$NGINX_ROOT\"\n cat < \"$NGINX_ROOT/index.html\"\n\n\n \n Hello World!\n \n \n \n

\n Hello World!\n

\n \n\n\nEOF\nfi\n " + }, + "profile": {}, + "options": { + "systems": [ + "aarch64-darwin", + "aarch64-linux", + "x86_64-darwin", + "x86_64-linux" + ], + "allow": { + "licenses": [] + }, + "semver": {} + }, + "services": { + "nginx": { + "command": "nginx -c \"$NGINX_CONFIG\" -e stderr", + "vars": null, + "is-daemon": true, + "shutdown": { + "command": "echo hi > /tmp/f; nginx -c \"$NGINX_CONFIG\" -s quit -e /Users/matthew/log" + }, + "systems": null + } + } + }, + "packages": [ + { + "attr_path": "nginx", + "broken": false, + "derivation": "/nix/store/fmcxnpii0pm525xpnbj6vg6mv1lp4200-nginx-1.26.2.drv", + "description": "Reverse proxy and lightweight webserver", + "install_id": "nginx", + "license": "[ BSD-2-Clause, BSD-2-Clause, BSD-2-Clause, BSD-2-Clause ]", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "nginx-1.26.2", + "pname": "nginx", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.26.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "doc": "/nix/store/5vkdjy3h1g3pk3fjrxqnyizbn32jfgzp-nginx-1.26.2-doc", + "out": "/nix/store/k9frc2f3fm38hdlp7l31qh8i5k6bgyzs-nginx-1.26.2" + }, + "system": "aarch64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "nginx", + "broken": false, + "derivation": "/nix/store/0my9cjk6mh2j149nv3asvz8ng7ch0ych-nginx-1.26.2.drv", + "description": "Reverse proxy and lightweight webserver", + "install_id": "nginx", + "license": "[ BSD-2-Clause, BSD-2-Clause, BSD-2-Clause, BSD-2-Clause ]", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "nginx-1.26.2", + "pname": "nginx", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.26.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "doc": "/nix/store/i3km1iw3wiklc71zsjqrlmbmazc8w4qj-nginx-1.26.2-doc", + "out": "/nix/store/dvgb54l52kya0wpmb256h35zasan436k-nginx-1.26.2" + }, + "system": "aarch64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "nginx", + "broken": false, + "derivation": "/nix/store/y9vivi98kkl6z9r79hib1yy7srpjzvka-nginx-1.26.2.drv", + "description": "Reverse proxy and lightweight webserver", + "install_id": "nginx", + "license": "[ BSD-2-Clause, BSD-2-Clause, BSD-2-Clause, BSD-2-Clause ]", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "nginx-1.26.2", + "pname": "nginx", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.26.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "doc": "/nix/store/rbrkmql8ws5a2cc3pfjqak0kykxaf9zm-nginx-1.26.2-doc", + "out": "/nix/store/w95cz4b6hbshxbk7ykvfqzw9lpp776fd-nginx-1.26.2" + }, + "system": "x86_64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "nginx", + "broken": false, + "derivation": "/nix/store/ba6l07q1by884jsi1pmcjbva4h25q1vx-nginx-1.26.2.drv", + "description": "Reverse proxy and lightweight webserver", + "install_id": "nginx", + "license": "[ BSD-2-Clause, BSD-2-Clause, BSD-2-Clause, BSD-2-Clause ]", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "nginx-1.26.2", + "pname": "nginx", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.26.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "doc": "/nix/store/11ksaavr27994iqqcq4vlmbci8jcgjk0-nginx-1.26.2-doc", + "out": "/nix/store/rdc8w0yiw5n4k9w8l0d31738614cj2a6-nginx-1.26.2" + }, + "system": "x86_64-linux", + "group": "toplevel", + "priority": 5 + } + ] +} \ No newline at end of file diff --git a/nginx/.flox/env/manifest.toml b/nginx/.flox/env/manifest.toml new file mode 100644 index 0000000..c681720 --- /dev/null +++ b/nginx/.flox/env/manifest.toml @@ -0,0 +1,66 @@ +version = 1 + + +[install] +nginx.pkg-path = "nginx" + +[hook] +on-activate = ''' +export NGINX_DIR="$FLOX_ENV_CACHE/nginx" +export NGINX_CONFIG="$NGINX_DIR/nginx.conf" +export NGINX_ROOT="$NGINX_DIR/www" + +if [ ! -e "$NGINX_CONFIG" ]; then + mkdir -p "$NGINX_DIR" + cat < "$NGINX_CONFIG" +lock_file $NGINX_DIR/nginx.lock; +pid $NGINX_DIR/nginx.pid; +events { +} +http { + server { + listen 8080; + root $NGINX_ROOT; + + location / { + } + + access_log $NGINX_DIR/access.log; + } +} +EOF + +fi + +if [ ! -e "$NGINX_ROOT/index.html" ]; then + mkdir -p "$NGINX_ROOT" + cat < "$NGINX_ROOT/index.html" + + + + Hello World! + + + +

+ Hello World! +

+ + + +EOF +fi + ''' + +[services.nginx] +command = "nginx -c \"$NGINX_CONFIG\" -e stderr" +is-daemon = true +shutdown.command = "echo hi > /tmp/f; nginx -c \"$NGINX_CONFIG\" -s quit -e /Users/matthew/log" + +[options] +systems = [ + "aarch64-darwin", + "aarch64-linux", + "x86_64-darwin", + "x86_64-linux" +] diff --git a/nginx/test.sh b/nginx/test.sh new file mode 100644 index 0000000..ec2b5f8 --- /dev/null +++ b/nginx/test.sh @@ -0,0 +1,3 @@ +set -euxo pipefail + +curl localhost:8080 | grep "Hello World!"