Files
nixpkgs/nixos/tests/web-apps/linkding-postgres.nix
squat 5c55071c5b nixos: introduce a service for linkding
This commit adds a new NixOS service for the linkding package. This
NixOS service runs 3 systemd services:
1. linkding-setup: this one-shot service bootstraps the creation of the
   runtime data directory and sets up the SQL database by running
   migrations, creating users, etc.
2. linkding: this is the main service, which runs linkding inside of
   uwsgi.
3. linkding-background-tasks: this is a sidecar service that runs
   `huey`, a task manager, which linkding uses to generate previews,
   downloads favicons, etc for your bookmarks.

Wherever possible, the NixOS service mirrors the configuration from the
upstream scripts/Docker compose.

I've validated that following configurations work on my own machines:
1. linkding with the sqlite3: this is the simplest way to run the
   linkding service, storing all DB data in the data directory. Task
   runner is confirmed working and favicons/previews are correctly
   generated.
2. linkding with postgresql: this is a trickier configuration that needs
   to pull in an optional-dependency. This is also confirmed working
   even against a non-local postgres instance.

Signed-off-by: squat <lserven@gmail.com>
2026-04-18 20:54:18 +02:00

43 lines
857 B
Nix

{ lib, ... }:
{
name = "linkding-postgres";
meta = {
maintainers = with lib.maintainers; [ squat ];
};
nodes.machine =
{ ... }:
{
services.linkding = {
enable = true;
port = 9090;
database = {
createLocally = true;
type = "postgres";
};
};
};
testScript = ''
machine.start()
machine.wait_for_unit("linkding.service")
machine.wait_for_open_port(9090)
with subtest("Login page loads"):
machine.succeed(
"curl -sSfL http://127.0.0.1:9090 | grep -i 'linkding'"
)
with subtest("Health endpoint responds"):
machine.succeed(
"curl -sSf http://127.0.0.1:9090/health"
)
with subtest("linkding-manage works"):
machine.succeed(
"linkding-manage version"
)
'';
}