add nix flake devshell and process-compose

mirrors youngstartup setup. flake provides php 8.4, composer,
nodejs, postgresql, cypress, typescript, process-compose. shellHook
seeds a per-repo postgres cluster at .postgres/. process-compose
orchestrates postgres + backend (laravel) + vite (vue spa) for
local dev. .envrc auto-loads the flake via direnv. mailpit and
gitlab-ci-local omitted - not needed for tide blogging app.
This commit is contained in:
yisroel 2026-05-06 14:38:29 +03:00
parent 91cc08614d
commit d1df7a6a42
5 changed files with 165 additions and 0 deletions

10
.envrc Normal file
View file

@ -0,0 +1,10 @@
# Load the flake environment
use flake
# Use PHP and Node layouts
layout php
layout node
# Watch for dependency changes
watch_file composer.json
watch_file package.json

9
.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
# Nix devshell artefacts
/.postgres/
/.direnv/
result
result-*
# Process-compose state
/.pc.*
process-compose-*.log

61
flake.lock generated Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1777954456,
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
"owner": "NixOs",
"repo": "nixpkgs",
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
"type": "github"
},
"original": {
"owner": "NixOs",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

48
flake.nix Normal file
View file

@ -0,0 +1,48 @@
{
inputs = {
nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
onefetch
php
phpPackages.composer
phpPackages.php-codesniffer
vscode-langservers-extracted
sqlite
nodejs
nixfmt-rfc-style
nixfmt-tree
cypress
yaml-language-server
typescript
postgresql
process-compose
];
shellHook = ''
export PGDATA="$PWD/.postgres"
export PGHOST="$PGDATA"
export PGUSER="postgres"
export PGDATABASE="postgres"
if [ ! -d "$PGDATA" ]; then
echo "[pg] initializing cluster at $PGDATA"
initdb --auth=trust --username=postgres --no-locale --encoding=UTF8 >/dev/null
{
echo "listen_addresses = '127.0.0.1'"
echo "unix_socket_directories = '$PGDATA'"
} >> "$PGDATA/postgresql.conf"
fi
echo "[dev] run 'process-compose up' to start postgres + backend + vite"
'';
};
});
}

37
process-compose.yaml Normal file
View file

@ -0,0 +1,37 @@
version: "0.5"
processes:
postgres:
command: postgres -D "$PGDATA" -k "$PGDATA" -c listen_addresses=127.0.0.1
shutdown:
signal: 2
readiness_probe:
exec:
command: pg_isready -h "$PGDATA"
initial_delay_seconds: 1
period_seconds: 2
backend:
command: php artisan serve --host=127.0.0.1 --port=8000
working_dir: ./backend
depends_on:
postgres:
condition: process_healthy
readiness_probe:
http_get:
host: 127.0.0.1
port: 8000
path: /up
initial_delay_seconds: 2
period_seconds: 10
vite:
command: npm run dev
working_dir: ./frontend/blog_portal
readiness_probe:
http_get:
host: 127.0.0.1
port: 5173
path: /
initial_delay_seconds: 2
period_seconds: 2