I've moved to developing my Haskell stuff in a NixOS VM. In this post I'll sketch out a development/deployment workflow.
Aside: Why Nix? NixOS provides a declarative and safe way to interact with Linux. Nix is great for Haskell because:
- binaries = fast builds
- reliable package sets = less errors
nix-env -iA nixos.cabal2nix or similar). This will help you generate Nix code from your cabal packages.
shell.nix file for local development:
You can then configure and run repls and tests like:
nix-copy-closure command provides a quick way to get some software on another NixOS machine. It may work for you if your needs are simple. NixOps is a more complicated tool for describing infra and deploying code.
Saluton is an interactive repo for learning EC2 deployments using NixOps. Here's an overview:
- You need a
~/.ec2-keysfile in the format: ID KEY NAME
- Build a
cabal2nix . > project.nix
- Create a
default.nixto call it:
In another directory (perhaps
../) write your physical network description and your services description. The former describes AWS attributes like instance type, the latter can be used to boot your app via systemd (for example).
Now you can create the configuration:
And fire at will!
When you make changes, simply:
And deploy again! Ping me if I can help out!