Make 'nix run' spin up the whole stack in one command

This commit is contained in:
kurogeek committed 2026-10-15 07:36:56 +00:00
1 parent c8b08fe258
commit 4d77464988
3 files changed
+56 -26

No files matched your search

+27 -18
View File
@@ -7,27 +7,36 @@
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:
let
php = pkgs.php83;
in
{
default = pkgs.mkShell {
packages = [
php
php.packages.composer
pkgs.mariadb
pkgs.nodejs_22
];
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'"
'';
};
});
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";
};
});
};
}