Using devenv with laravel
DevEnv is another amazing tool coming from the nix community that allows you to define a full dev environment including:
- language support
- tasks
- processes
There's a little thing I found though: You have to add .devenv and .direnv to be ignored by vite's watcher or your app will crawl
server: {
cors: true,
watch: {
ignored: ['**/storage/framework/views/**', '**/.devenv/**', '**/.direnv/**'],
},
},
The devenv setup
In your devenv.nix
{
pkgs,
lib,
config,
inputs,
...
}:
{
packages = with pkgs; [
frankenphp
];
languages.php.enable = true;
languages.javascript = {
enable = true;
bun = {
enable = true;
install.enable = true;
};
};
processes = {
server = {
exec = "frankenphp php-server --listen :8000 --root public/";
};
frontend_build = {
exec = "bun run dev";
};
};
services.postgres = {
enable = true;
listen_addresses = "127.0.0.1";
port = 5432;
initialDatabases = [
{
name = "betterhelp";
user = "laravel";
pass = "password";
}
];
};
}
After that, simply doing devenv up or devenv up -d (to start the processes in the background) will put up
- Postgres
- The app server
- The vite watcher process to compile front end assets