Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
teto committed Aug 15, 2023
1 parent 49e9bcc commit e3dc06f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 21 deletions.
61 changes: 41 additions & 20 deletions contrib/nixos-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ let

s3Login = "mylogin";
s3Password = "mypassword";
s3Region = "eu-central-1";

postgresPassword = "postgresPassword";

in
{
Expand Down Expand Up @@ -57,6 +60,11 @@ in
enable = true;
enableTCPIP = true;

# <user>
initialScript = pkgs.writeText "init-sql-script" ''
alter user postgres with password '${postgresPassword}';
'';

ensureDatabases = [ "core" ];
# ensureUsers = [
# {
Expand Down Expand Up @@ -122,15 +130,43 @@ in
pkgs.curl
pkgs.jq
pkgs.luaPackages.lapis
# pkgs.nginx
pkgs.openresty
# pkgs.sassc
# pkgs.openresty
# pkgs.discount # for
# pkgs.nodePackages.coffee-script

];

# TODO pass a special config ?
environment.sessionVariables = {
POSTGRESQL_CONNECTION = "user=postgres password= host=postgres dbname=core";
};

networking.firewall.enable = false;
systemd.services.luarocks-site = {
description = "luarocks-ste";
wantedBy = [ "multi-user.target" ];

path = [
# pkgs.nginx
pkgs.openresty
];

serviceConfig = {
Environment = [
"POSTGRESQL_CONNECTION='user=postgres password=${postgresPassword} host=postgres dbname=core'"
"AWS_REGION=${s3Region}"
# "AWS_ACCESS_KEY_ID=${s3Login}"
# "AWS_SECRET_ACCESS_KEY=${s3Password}"
];

# TODO it should have access to nginx
ExecStart = "${pkgs.luaPackages.lapis}/bin/lapis serve";
};
};

networking.firewall.enable = false;
};

};
Expand All @@ -145,25 +181,9 @@ in
# inherit (nodes.machine.config.services) redis;
# in
# with subtest("All user permissions are set according to the ensureClauses attr"):

''
start_all()
# server-redis.wait_for_unit("redis")
minio.start()
postgres.start()
# The unix socket is accessible to the redis group
# machine.succeed('su member -c "redis-cli ping | grep PONG"')
# redis.succeed('su member-test -c "redis-cli ping | grep PONG"')
# redis.succeed("redis-cli ping | grep PONG")
# redis.succeed("redis-cli -s ${nodes.redis.services.redis.servers."test".unixSocket} ping | grep PONG")
server.start()
# TODO wait for networking
# postgres.wait_for_unit("postgresql")
# server.shell_interact
minio.wait_for_unit("minio")
Expand All @@ -172,8 +192,9 @@ in
# we would need an s3 equivalent to test further ?
# we setup POSTGRESQL_CONNECTION to allow the workers to
server.send_monitor_command("hostfwd_add tcp::8081-:8082")
server.execute("lapis server")
# server.send_monitor_command("hostfwd_add tcp::8081-:8082")
# jinko.forward_port(8082, 8081)
server.start_job("luarocks-site")
'';
Expand Down
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
[
pkgs.tup
# pkgs.lua5_1.pkgs.luarocks
# expat.dev # for the lua
luaEnv
pkgs.sassc
# expat.dev # for the lua
pkgs.openresty
pkgs.discount # for
pkgs.nodePackages.coffee-script
Expand Down Expand Up @@ -84,6 +84,7 @@
};
# export PATH="$PATH:~/.luarocks/bin"
# export LUA_PATH='.luarocks/share/lua/5.1/?.lua;;'
# export LAPIS_ENVIRONMENT to change environment
in
''
export LUAROCKS_CONFIG=${luarocksConfigFile}
Expand Down
2 changes: 2 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# the ${{ }}
# https://leafo.net/lapis/reference/getting_started.html#creating-an-application/nginx-configuration
worker_processes ${{NUM_WORKERS}};
error_log ${{NOTICE_LOG}} notice;
daemon ${{DAEMON}};
Expand Down

0 comments on commit e3dc06f

Please sign in to comment.