I am trying to setup a MariaDB - PHP - Node / Elm devenv. I am following this topic to install mariadb in a flake.
My flake.nix:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
};
outputs = { self, nixpkgs, devenv, systems, ... }@inputs:
let forEachSystem = nixpkgs.lib.genAttrs (import systems);
in {
devShells = forEachSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [{
packages = with pkgs; [
dhall
asciidoctor-with-extensions
phpPackages.composer
php82Packages.deployer
php
nodejs
inotify-tools
elmPackages.elm
sass
mariadb
];
dotenv.enable = true;
# https://devenv.sh/reference/options/
services.mysql.package = pkgs.mariadb;
services.mysql.enable = true;
# https://shyim.me/blog/devenv-compose-developer-environment-for-php-with-nix/
services.mysql.initialDatabases = [{ name = "app"; }];
services.mysql.ensureUsers = [
{
name = "app";
password = "app";
ensurePermissions = { "app.*" = "ALL PRIVILEGES"; };
}
];
# Project specific MySQL config like require always a primary key
services.mysql.settings.mysqld = {
"sql_require_primary_key" = "on";
};
}];
};
});
};
}
I am starting the devenv using nix develop --impure
. I am trying to connect using mariadb -uapp -p
but then receive
Enter password:
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)
It seems mysql is not running as ps aux | grep mysql
only shows the grep task.
How can I resolve/debug this issue? Is there any log to check?
❯ nix --version
nix (Nix) 2.11.1