Deploying and testing nix projects with databases on non-nixos systems

How do you go about developing and deploying apps with nix that use databases such as mysql or mongodb?

Getting compiler, compiling/linking is relatively easy with flakes. What is the best practice to add a database?

I want a configuration that can be used in dev shell (nix develop) and that can be deployed in production that runs Ubuntu.

Adding mysql to buildInputs gives me a binary in scope but not , what’s the best approach to deal with starting/stopping/logging, etc?

What is the best practice to add a database?

I think would be creating a dev shell with database and a package without it. Flakes let you have different shells and packages.

https://coggle.it/diagram/ZVb6WicP9Med_cMb/t/nix-flakes#e51f070cdca72db5ee350975

DevEnv and DevShell has some tools for that.

For non dev (PRD/QA), I would try system-manager, but I never had the chance. Other option would be create docker images.

You probably will have some question about password management.

1 Like