mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 15:13:46 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
106 lines
3.4 KiB
Nix
106 lines
3.4 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, lib, ... }:
|
|
let
|
|
luaLibs = [
|
|
pkgs.lua.pkgs.markdown
|
|
];
|
|
|
|
getLuaPath = lib: "${lib}/share/lua/${pkgs.lua.luaversion}/?.lua";
|
|
luaPath = lib.concatStringsSep ";" (map getLuaPath luaLibs);
|
|
in
|
|
{
|
|
name = "openresty-lua";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ bbigras ];
|
|
};
|
|
|
|
nodes = {
|
|
webserver =
|
|
{ pkgs, lib, ... }:
|
|
{
|
|
networking = {
|
|
extraHosts = ''
|
|
127.0.0.1 default.test
|
|
127.0.0.1 sandbox.test
|
|
'';
|
|
};
|
|
services.nginx = {
|
|
enable = true;
|
|
package = pkgs.openresty;
|
|
|
|
commonHttpConfig = ''
|
|
lua_package_path '${luaPath};;';
|
|
'';
|
|
|
|
virtualHosts."default.test" = {
|
|
default = true;
|
|
locations."/" = {
|
|
extraConfig = ''
|
|
default_type text/html;
|
|
access_by_lua '
|
|
local markdown = require "markdown"
|
|
markdown("source")
|
|
';
|
|
'';
|
|
};
|
|
};
|
|
|
|
virtualHosts."sandbox.test" = {
|
|
locations."/test1-write" = {
|
|
extraConfig = ''
|
|
content_by_lua_block {
|
|
local create = os.execute('${pkgs.coreutils}/bin/mkdir /tmp/test1-read')
|
|
local create = os.execute('${pkgs.coreutils}/bin/touch /tmp/test1-read/foo.txt')
|
|
local echo = os.execute('${pkgs.coreutils}/bin/echo worked > /tmp/test1-read/foo.txt')
|
|
}
|
|
'';
|
|
};
|
|
locations."/test1-read" = {
|
|
root = "/tmp";
|
|
};
|
|
locations."/test2-write" = {
|
|
extraConfig = ''
|
|
content_by_lua_block {
|
|
local create = os.execute('${pkgs.coreutils}/bin/mkdir /var/web/test2-read')
|
|
local create = os.execute('${pkgs.coreutils}/bin/touch /var/web/test2-read/bar.txt')
|
|
local echo = os.execute('${pkgs.coreutils}/bin/echo error-worked > /var/web/test2-read/bar.txt')
|
|
}
|
|
'';
|
|
};
|
|
locations."/test2-read" = {
|
|
root = "/var/web";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript =
|
|
{ nodes, ... }:
|
|
''
|
|
url = "http://localhost"
|
|
|
|
webserver.wait_for_unit("nginx")
|
|
webserver.wait_for_open_port(80)
|
|
|
|
http_code = webserver.succeed(
|
|
f"curl -w '%{{http_code}}' --head --fail {url}"
|
|
)
|
|
assert http_code.split("\n")[-1] == "200"
|
|
|
|
# This test checks the creation and reading of a file in sandbox mode.
|
|
# Checking write in temporary folder
|
|
webserver.succeed("$(curl -vvv http://sandbox.test/test1-write)")
|
|
webserver.succeed('test "$(curl -fvvv http://sandbox.test/test1-read/foo.txt)" = worked')
|
|
# Checking write in protected folder. In sandbox mode for the nginx service, the folder /var/web is mounted
|
|
# in read-only mode.
|
|
webserver.succeed("mkdir -p /var/web")
|
|
webserver.succeed("chown nginx:nginx /var/web")
|
|
webserver.succeed("$(curl -vvv http://sandbox.test/test2-write)")
|
|
assert "404 Not Found" in machine.succeed(
|
|
"curl -vvv -s http://sandbox.test/test2-read/bar.txt"
|
|
)
|
|
'';
|
|
}
|
|
)
|