diff options
author | Vika <vika@fireburn.ru> | 2023-07-09 01:39:58 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2023-07-09 01:39:58 +0300 |
commit | a863a2b27902d2d8b87dae07c03f94e96d06d92b (patch) | |
tree | 960487de597f02f28b44d77966189d86d885e43c /kittybox.nix | |
parent | 63148c502c11fcbe99f335c5d214fba84eda1c1c (diff) | |
download | kittybox-a863a2b27902d2d8b87dae07c03f94e96d06d92b.tar.zst |
Implement Postgres backend
A single giga-commit that took me weeks to produce. I know, this is not exactly the best thing ever — but I wanted to experiment first before "committing" to the implementation, so that I would produce the best solution.
Diffstat (limited to 'kittybox.nix')
-rw-r--r-- | kittybox.nix | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/kittybox.nix b/kittybox.nix index d7577fd..ccf3ea8 100644 --- a/kittybox.nix +++ b/kittybox.nix @@ -1,8 +1,10 @@ { stdenv, lib, naersk, lld, mold, typescript , useWebAuthn ? false, openssl, zlib, pkg-config, protobuf +, usePostgres ? true, postgresql, postgresqlTestHook , nixosTests }: assert useWebAuthn -> openssl != null && pkg-config != null; +assert usePostgres -> postgresql != null && postgresqlTestHook != null; naersk.buildPackage { pname = "kittybox"; @@ -12,13 +14,24 @@ naersk.buildPackage { doCheck = stdenv.hostPlatform == stdenv.targetPlatform; cargoOptions = x: x ++ (lib.optionals useWebAuthn [ - "--no-default-features" "--features=\"webauthn\"" + "--no-default-features" "--features=\"webauthn${lib.optionalString usePostgres " sqlx"}\"" ]); buildInputs = lib.optional useWebAuthn openssl; nativeBuildInputs = [ typescript ] ++ (lib.optional useWebAuthn pkg-config); + nativeCheckInputs = lib.optionals usePostgres [ + postgresql postgresqlTestHook + ]; + + # Tests create arbitrary databases; we need to be prepared for that + postgresqlTestUserOptions = "LOGIN SUPERUSER"; + postgresqlTestSetupPost = '' + export DATABASE_URL="postgres://localhost?host=$PGHOST&user=$PGUSER&dbname=$PGDATABASE" + ''; + passthru = { tests = nixosTests; + hasPostgres = usePostgres; }; meta = with lib.meta; { |