-
-
Notifications
You must be signed in to change notification settings - Fork 241
feat: add nix-flake addon support and related configurations #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@karol-broda is attempting to deploy a commit to the Better T Stack Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughAdds a new "nix-flake" addon: registers it across types, CLI, and web, adds templates (flake and .envrc), maps Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/cli/templates/addons/nix-flake/flake.nix.hbs (1)
21-21: Consider parameterizing Node.js version for easier maintenance.The Node.js version is hardcoded to
nodejs_22. As new LTS versions are released, this will require manual template updates.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
flake.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
.envrcapps/cli/src/constants.tsapps/cli/src/helpers/core/template-manager.tsapps/cli/src/prompts/addons.tsapps/cli/templates/addons/nix-flake/_envrc.hbsapps/cli/templates/addons/nix-flake/flake.nix.hbsapps/cli/test/addons.test.tsflake.nixpackages/types/src/schemas.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.hbs
📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)
**/*.hbs: In Handlebars templates, avoid generic if/else blocks. Write explicit conditions, such as: use if (eq orm "prisma") for Prisma, and else if (eq orm "drizzle") for Drizzle
Escape the '{{' in Handlebars templates like '{{'
Files:
apps/cli/templates/addons/nix-flake/flake.nix.hbsapps/cli/templates/addons/nix-flake/_envrc.hbs
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)
Define functions using the standard function declaration syntax, not arrow functions
Files:
apps/cli/src/prompts/addons.tsapps/cli/src/constants.tsapps/cli/test/addons.test.tsapps/cli/src/helpers/core/template-manager.tspackages/types/src/schemas.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)
**/*.{ts,tsx}: Use TypeScript type aliases instead of interface declarations
Do not use explicit return types
Files:
apps/cli/src/prompts/addons.tsapps/cli/src/constants.tsapps/cli/test/addons.test.tsapps/cli/src/helpers/core/template-manager.tspackages/types/src/schemas.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
**/*.{ts,tsx,js,jsx}: Usebun <file>instead ofnode <file>orts-node <file>for running TypeScript/JavaScript files
Bun automatically loads .env files, so don't use the dotenv package
UseBun.serve()which supports WebSockets, HTTPS, and routes instead ofexpress
Usebun:sqlitemodule for SQLite instead ofbetter-sqlite3
UseBun.redisfor Redis instead ofioredis
UseBun.sqlfor Postgres instead ofpgorpostgres.js
Use built-inWebSocketinstead of thewspackage
PreferBun.fileovernode:fsreadFile/writeFile methods
UseBun.$template literal syntax instead ofexecafor shell command execution
Import .css files directly in TypeScript/JavaScript files; Bun's CSS bundler will handle bundling
Run server withbun --hot <file>to enable hot reloading during development
Files:
apps/cli/src/prompts/addons.tsapps/cli/src/constants.tsapps/cli/test/addons.test.tsapps/cli/src/helpers/core/template-manager.tspackages/types/src/schemas.ts
**/*.{ts,tsx,js,jsx,css}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Use
bun build <file>instead ofwebpackoresbuildfor bundling TypeScript, JavaScript, and CSS files
Files:
apps/cli/src/prompts/addons.tsapps/cli/src/constants.tsapps/cli/test/addons.test.tsapps/cli/src/helpers/core/template-manager.tspackages/types/src/schemas.ts
**/*.{html,tsx,ts,jsx,js}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Use HTML imports with
Bun.serve()for frontend instead of Vite
Files:
apps/cli/src/prompts/addons.tsapps/cli/src/constants.tsapps/cli/test/addons.test.tsapps/cli/src/helpers/core/template-manager.tspackages/types/src/schemas.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
**/*.test.{ts,tsx,js,jsx}: Usebun testinstead ofjestorvitestfor running tests
Usebun:testmodule withtestandexpectfunctions for writing tests
Files:
apps/cli/test/addons.test.ts
🧠 Learnings (2)
📚 Learning: 2025-12-18T19:15:48.478Z
Learnt from: therealsamyak
Repo: AmanVarshney01/create-better-t-stack PR: 711
File: apps/cli/src/helpers/addons/ultracite-setup.ts:200-205
Timestamp: 2025-12-18T19:15:48.478Z
Learning: In apps/cli/src/helpers/addons/ultracite-setup.ts, the Ultracite CLI's `--integrations` flag requires git hooks to be passed as a single space-separated string (e.g., `gitHooks.join(" ")`) rather than using the spread operator like other Ultracite flags. This has been tested and confirmed to work.
Applied to files:
apps/cli/test/addons.test.ts
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Bun automatically loads .env files, so don't use the dotenv package
Applied to files:
apps/cli/src/helpers/core/template-manager.ts
🔇 Additional comments (12)
apps/cli/src/helpers/core/template-manager.ts (1)
38-39: LGTM!The
_envrcto.envrcmapping follows the established pattern for special dotfile handling alongside_gitignoreand_npmrc.apps/cli/templates/addons/nix-flake/_envrc.hbs (1)
1-2: LGTM!Standard direnv configuration for Nix flake environments. The template correctly enables the flake-based dev shell.
.envrc (1)
1-1: Verify the intentional difference between root and template.envrcfiles.The root
.envrcuses--impurewhile the generated template (_envrc.hbs) uses plainuse flake. This may be intentional—the--impureflag allows access to environment variables during flake evaluation, which might be needed for the CLI development but not for generated projects. Please confirm this distinction is deliberate.packages/types/src/schemas.ts (1)
47-47: LGTM!The
nix-flakeaddon is properly added to the schema enum, maintaining consistency with other addon entries.apps/cli/src/constants.ts (1)
192-192: LGTM!The
nix-flakeaddon is correctly registered as a universal addon with no frontend restrictions, consistent with similar addons likebiome,husky, andturborepo.apps/cli/test/addons.test.ts (2)
7-7: LGTM!The
nix-flakeaddon is correctly added to the universal addons test list, ensuring it receives proper test coverage.
291-291: LGTM!Consistent addition to the
testableAddonsarray ensures end-to-end test coverage for the new addon.apps/cli/src/prompts/addons.ts (2)
66-69: LGTM!Clear and descriptive label/hint for the Nix Flake addon. The hint accurately conveys the reproducible development environment benefit.
81-81: LGTM!Appropriate grouping under "Other" alongside similar infrastructure addons.
flake.nix (2)
10-35: LGTM!Well-structured multi-system flake configuration with proper devShell definitions for all major platforms. The
mkShellForhelper cleanly abstracts the per-system shell creation, and the shellHook provides useful version feedback during development.
4-8: No action required. The flake correctly referencesnixos-25.11, which is a valid, currently available stable release.apps/cli/templates/addons/nix-flake/flake.nix.hbs (1)
18-22: LGTM! Conditional logic follows coding guidelines.The explicit
if (eq runtime "bun")andelse if (eq runtime "node")conditions correctly follow the coding guideline to avoid generic if/else blocks. The Handlebars syntax is properly used.
| inputs = \{ | ||
| nixpkgs = \{ | ||
| url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align nixpkgs input with root flake for consistency and reproducibility.
The template uses nixos-unstable while the root flake.nix pins to nixos-25.11. This inconsistency can lead to:
- Reproducibility issues across environments
- Unexpected breaking changes when unstable updates
- Different behavior between the template-generated projects and the root configuration
Consider aligning with the root flake's approach by using a stable release branch.
🔎 Proposed fix
inputs = \{
nixpkgs = \{
- url = "github:NixOS/nixpkgs/nixos-unstable";
+ url = "github:NixOS/nixpkgs/nixos-25.11";
};
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| inputs = \{ | |
| nixpkgs = \{ | |
| url = "github:NixOS/nixpkgs/nixos-unstable"; | |
| }; | |
| }; | |
| inputs = \{ | |
| nixpkgs = \{ | |
| url = "github:NixOS/nixpkgs/nixos-25.11"; | |
| }; | |
| }; |
🤖 Prompt for AI Agents
In apps/cli/templates/addons/nix-flake/flake.nix.hbs around lines 4-8, the
nixpkgs input is pinned to "nixos-unstable", which diverges from the root
flake's stable pin (nixos-25.11); update the template to use the same stable
release branch or the exact pin used by the root flake (e.g., change the url to
match "github:NixOS/nixpkgs/nixos-25.11" or wire the template to read the root
flake's pinned ref) so generated projects use the same nixpkgs version for
reproducibility and consistency.
|
interesting... is the PR complete? @karol-broda |
|
yes, it should be complete. the only remaining question is whether we want to include a nix lock file to pin bun as well, since node major is pinned but bun would track nixpkgs unstable and update as nixpkgs updates @AmanVarshney01 |
|
maybe adding a nix svg icon to the r2 bucket, also i now added it to the web builder constants, i only tested the cli directly so i forgot to do that |
|
@AmanVarshney01 actually , i just started writing and thought that it maybe would be good to also add database tooling or stuff like that in the flake, like psql or something. also i forgot to handle adding wrangler |
|
yea now i think it should handle everything |
adds a nix-flake addon that generates a flake.nix and .envrc for the project
the flake exposes a devshell with the appropriate runtime (bun or node) based on what you picked during setup. also includes docker-compose if you're using docker for your db
Summary by CodeRabbit
New Features
Documentation
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.