In this tutorial, you will learn how to add flake.nix
to a TypeScript web application.
Initialize a new project
We will be using a framework-specific scaffolder to initialize a project. An alternative way is to use an external service such as StackBlitz and Bolt.new. The flake template should work the same way, but I don't provide any specific support for those services.
We need one of
npm
,yarn
,pnpm
, orbun
. Bothnpm
andbun
are available directly from Nixpkgs.If you prefer
yarn
orpnpm
, you will probably need bothyarn
/pnpm
andnpm
. To make the multiple packages available, you can use the classicnix-shell
command, or use a devshell in my personal repository.or
or
Then follow an instruction for the framework of your choice to initialize the project. Below are some links:
Add flake.nix to the project
Initialize the template from the root directory of the project:
Open
flake.nix
and comment outyarn
,pnpm
, orbun
in thebuildInputs
field of the default shell, depending on the package manager of your choice.Add
.envrc
:Allow direnv:
Developing
You can use npm
, yarn
, pnpm
, or bun
to develop your application as you would normally do.