43 lines
1.4 KiB
Nix
43 lines
1.4 KiB
Nix
{
|
|
description = "Dev shell for think.greaterchiangmai.com (frontend + backend Laravel apps)";
|
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
forAll = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
|
toolchain = pkgs:
|
|
let php = pkgs.php83; in
|
|
[ php php.packages.composer pkgs.mariadb pkgs.nodejs_22 ];
|
|
in
|
|
{
|
|
devShells = forAll (pkgs: {
|
|
default = pkgs.mkShell {
|
|
packages = toolchain pkgs;
|
|
shellHook = ''
|
|
export DEV_ROOT="$PWD"
|
|
export PATH="$DEV_ROOT/dev:$PATH"
|
|
echo "think-greaterchiangmai dev shell — run 'dev help'"
|
|
'';
|
|
};
|
|
});
|
|
|
|
# `nix run` = `dev up` with the toolchain on PATH, no `nix develop` needed.
|
|
# Runs the checked-out dev/dev (not a store copy) so state lands in the working tree.
|
|
apps = forAll (pkgs: {
|
|
default = {
|
|
type = "app";
|
|
program = toString (pkgs.writeShellApplication {
|
|
name = "dev";
|
|
runtimeInputs = toolchain pkgs;
|
|
text = ''
|
|
[ -x "$PWD/dev/dev" ] || { echo "run from the repo root (dev/dev not found in $PWD)" >&2; exit 1; }
|
|
DEV_ROOT="$PWD" exec "$PWD/dev/dev" "''${@:-up}"
|
|
'';
|
|
}) + "/bin/dev";
|
|
};
|
|
});
|
|
};
|
|
}
|