diff --git a/docs/operations/development.md b/docs/operations/development.md index 1cbf09c16008..fcda170bea41 100644 --- a/docs/operations/development.md +++ b/docs/operations/development.md @@ -15,6 +15,18 @@ a new browser. Prefer a container? See [Dev container](../internals/devcontainer.md) for VS Code and Codespaces setup. +### Nix + +A `flake.nix` at the repo root provides a dev shell with the toolchain matching CI +(Node 24, pnpm, Rust stable, and the Linux desktop build prerequisites). With Nix and +flakes enabled: + +```sh +nix develop +``` + +Install the `vp` task runner once (it is not in nixpkgs); the shell prints the command if it is missing. After installing it, exit and re-enter `nix develop`, then `vp i` and `vp run dev` work as above. Regenerate `flake.lock` with `nix flake lock` when bumping the pinned nixpkgs revision. + ## Choosing a dev process Use `vp run dev` for server and web, or `vp run dev:desktop` for the Electron client. diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000000..fe8d3b9fbdef --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1789640129, + "narHash": "sha256-RjR8AyvGlWuw16XRj7C1YDEw4E27ciuyPeB2nDMzgTU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a32edd7654519351e48e80372a928df336394670", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000000..7651ead65fa6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,72 @@ +{ + description = "T3 Code development shell"; + + inputs = { + # nixpkgs-unstable branch; the resolved revision is pinned by flake.lock. + # Regenerate with: nix flake lock (or bump with: nix flake update nixpkgs) + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = + { nixpkgs, ... }: + let + forAllSystems = + function: + nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( + system: function nixpkgs.legacyPackages.${system} + ); + in + { + formatter = forAllSystems (pkgs: pkgs.alejandra); + + devShells = forAllSystems ( + pkgs: + let + inherit (pkgs) lib; + in + { + default = pkgs.mkShell { + packages = + with pkgs; + [ + # Node 24 (engines.node in package.json) + pnpm for `vp i`. + nodejs_24 + pnpm + + # The `vp` repo task runner (installed separately, see below). + # Rust stable: native/resource-monitor (cargo fmt + test run in CI). + cargo + rustc + rustfmt + clippy + + # node-gyp fallback for node-pty (its prebuilds are mac/win only). + python3 + gnumake + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + gcc + pkg-config + # browser-secret helper links against the host's libsecret. + libsecret + imagemagick + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # clang toolchain for node-gyp on macOS. + clang + ]; + + # The Vite+ CLI (`vp`) is not packaged in nixpkgs. Install it once: + # curl -fsSL https://vite.plus | bash + # with VP_NODE_MANAGER=no so it reuses this shell's Node. + shellHook = '' + if ! command -v vp >/dev/null 2>&1; then + echo "note: 'vp' not found. Install it with:" >&2 + echo " curl -fsSL https://vite.plus | VP_NODE_MANAGER=no bash" >&2 + fi + ''; + }; + } + ); + }; +}