mkdir my-project
cd my-project
nix flake init --refresh -t github:cor/flake-templates\#svelte
You will need to run the following commands once in order to create your Svelte app:
nix develop
npm create svelte@latest .
echo "result" >> .gitignore
echo ".direnv" >> .gitignore
yarn
yarn add -D @sveltejs/adapter-node
Then, open the file svelte.config.js
, and change the first line from:
import adapter from '@sveltejs/adapter-auto';
to
import adapter from '@sveltejs/adapter-node';
(If this doesn't work, check the adapter-node docs).
Finally, run
git init
git add -A
git commit -m "init"
You can now reproducibly build and run your Svelte project with Nix!
ORIGIN=http://localhost:3000 nix run
nix develop
nix build