add services.tide nixos module
Exposes the laravel backend behind phpfpm + nginx and the vue frontend as a static vhost. Wires postgres, runtime tmpfiles for laravel's writable storage/ and bootstrap/cache/, and a oneshot tide-migrate service for migrations and config caching.
This commit is contained in:
parent
b7db23b6aa
commit
83f53355be
2 changed files with 389 additions and 42 deletions
103
flake.nix
103
flake.nix
|
|
@ -4,50 +4,69 @@
|
|||
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
|
||||
mailpit
|
||||
];
|
||||
let
|
||||
perSystem = utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
packages = {
|
||||
tide-backend = pkgs.callPackage ./nix/packages/backend.nix { };
|
||||
tide-frontend = pkgs.callPackage ./nix/packages/frontend.nix {
|
||||
apiUrl = "https://apitide.yisroelbaum.com";
|
||||
};
|
||||
};
|
||||
|
||||
shellHook = ''
|
||||
# Anchor PGDATA to the repo root so subshells in subdirs
|
||||
# (e.g. backend/) reuse the same cluster instead of seeding
|
||||
# a stray .postgres there.
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
export PGDATA="$REPO_ROOT/.postgres"
|
||||
export PGHOST="$PGDATA"
|
||||
export PGUSER="postgres"
|
||||
export PGDATABASE="postgres"
|
||||
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
|
||||
mailpit
|
||||
];
|
||||
|
||||
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
|
||||
shellHook = ''
|
||||
# Anchor PGDATA to the repo root so subshells in subdirs
|
||||
# (e.g. backend/) reuse the same cluster instead of seeding
|
||||
# a stray .postgres there.
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
export PGDATA="$REPO_ROOT/.postgres"
|
||||
export PGHOST="$PGDATA"
|
||||
export PGUSER="postgres"
|
||||
export PGDATABASE="postgres"
|
||||
|
||||
echo "[dev] run 'process-compose up' to start postgres + backend + vite"
|
||||
'';
|
||||
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"
|
||||
'';
|
||||
};
|
||||
});
|
||||
in
|
||||
perSystem // {
|
||||
nixosModules.tide = import ./nix/module.nix { inherit self; };
|
||||
|
||||
overlays.default = final: prev: {
|
||||
tide-backend = final.callPackage ./nix/packages/backend.nix { };
|
||||
tide-frontend = final.callPackage ./nix/packages/frontend.nix {
|
||||
apiUrl = "https://apitide.yisroelbaum.com";
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue