Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples

Python data science

flk init --template python

flk add python312
flk add python312Packages.numpy
flk add python312Packages.pandas
flk add python312Packages.matplotlib
flk add python312Packages.scikit-learn
flk add jupyter

flk command add notebook "jupyter notebook --port=8888"
flk command add lab "jupyter lab --port=8888"
flk command add ipython "python -m IPython"

flk env add JUPYTER_CONFIG_DIR "./.jupyter"
flk env add PYTHONDONTWRITEBYTECODE "1"

flk activate
notebook

Rust web backend

flk init --template rust

flk add postgresql
flk add redis
flk add sqlx-cli
flk add cargo-watch

flk command add dev "cargo watch -x run"
flk command add test "cargo test --all-features"
flk command add migrate "sqlx migrate run"
flk command add db "psql $DATABASE_URL"

flk env add DATABASE_URL "postgresql://localhost/myapp"
flk env add REDIS_URL "redis://localhost:6379"
flk env add RUST_LOG "debug"

flk activate
dev

Node.js app

flk init --template node

flk add nodejs_20
flk add postgresql
flk add docker-compose
flk add nodePackages.typescript
flk add nodePackages.eslint

flk command add dev "npm run dev"
flk command add build "npm run build"
flk command add db-start "docker-compose up -d postgres"
flk command add db-stop "docker-compose down"
flk command add lint "npm run lint"
flk command add typecheck "tsc --noEmit"

flk env add NODE_ENV "development"
flk env add DATABASE_URL "postgresql://localhost/myapp"
flk env add PORT "3000"

flk activate
db-start
dev

Go service

flk init --template go

flk add go
flk add gopls
flk add golangci-lint
flk add mockgen
flk add protobuf

flk command add run "go run ./cmd/server"
flk command add test "go test ./..."
flk command add lint "golangci-lint run"
flk command add proto "protoc --go_out=. --go-grpc_out=. ./proto/*.proto"
flk command add build "go build -o bin/server ./cmd/server"

flk env add GOPROXY "https://proxy.golang.org,direct"
flk env add CGO_ENABLED "0"

flk activate
run

Monorepo with several profiles

flk init --template generic
flk profile add frontend --template node
flk profile add backend --template go

# shared tools go in the default profile
flk add docker-compose
flk add gnumake
flk command add up "docker-compose up -d"
flk command add down "docker-compose down"

# per-profile packages
flk add nodejs_20 -p frontend
flk add gopls -p backend

Inside the shell, switch frontend and switch backend move between them (needs the shell hook).

Pinned versions

flk add ripgrep --version 14.1.0
flk add nodejs --version 20.10.0
flk add python3 --version 3.11.6

flk list

Pins are stored in .flk/pins.nix.

direnv

flk direnv init
direnv allow

The environment now loads when you cd into the project and unloads when you leave.

Container export

flk export --format docker
flk export --format podman
flk export --format json     # writes flake.json