Initialize Nix Flake
Set up a Nix flake with bun and typescript for development.
Steps
- •
Check for existing flake.nix - ask before overwriting
- •
Get project name from directory name or package.json if exists
- •
Create
flake.nix:nix{ description = "<project-name>"; inputs = { 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: { default = pkgs.mkShell { packages = with pkgs; [ bun typescript lefthook ]; }; }); }; } - •
Create
.envrc(if not exists):codeuse flake
- •
Add to
.gitignore(if not present):code.direnv/ result
- •
Run
direnv allowif direnv is available - •
Summary: Created files, remind to run
nix developor let direnv activate
Notes
- •This creates a minimal devShell; add more packages as needed
- •For projects needing nix packaging (bun2nix), that's a separate enhancement
- •lefthook included by default for git hooks support