at master 2.0 kB view raw
1{ lib, ... }: 2{ 3 name = "Wakapi"; 4 5 nodes = { 6 wakapiPsql = { 7 services.wakapi = { 8 enable = true; 9 settings = { 10 server.port = 3000; # upstream default, set explicitly in case upstream changes it 11 db = { 12 dialect = "postgres"; # `createLocally` only supports postgres 13 host = "/run/postgresql"; 14 port = 5432; # service will fail if port is not set 15 name = "wakapi"; 16 user = "wakapi"; 17 }; 18 }; 19 20 # Automatically create our database 21 database.createLocally = true; # only works with Postgresql for now 22 23 # Created with `cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1` 24 # Prefer passwordSaltFile in production. 25 passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI"; 26 }; 27 }; 28 29 wakapiSqlite = { 30 services.wakapi = { 31 enable = true; 32 settings = { 33 server.port = 3001; 34 db = { 35 dialect = "sqlite3"; 36 name = "wakapi"; 37 user = "wakapi"; 38 }; 39 }; 40 41 passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI"; 42 }; 43 }; 44 }; 45 46 # Test that service works under both postgresql and sqlite3 47 # by starting all machines, and curling the default address. 48 # This is not very comprehensive for a test, but it should 49 # catch very basic mistakes in the module. 50 testScript = '' 51 with subtest("Test Wakapi with postgresql backend"): 52 wakapiPsql.start() 53 wakapiPsql.wait_for_unit("wakapi.service") 54 wakapiPsql.wait_for_open_port(3000) 55 wakapiPsql.succeed("curl --fail http://localhost:3000") 56 57 with subtest("Test Wakapi with sqlite3 backend"): 58 wakapiSqlite.start() 59 wakapiSqlite.wait_for_unit("wakapi.service") 60 wakapiSqlite.wait_for_open_port(3001) 61 wakapiSqlite.succeed("curl --fail http://localhost:3001") 62 ''; 63 64 meta.maintainers = [ lib.maintainers.NotAShelf ]; 65}