Skip to content

Deploy

In order to access all the options available in cardano.nix, the NixOS module provided by this project has to be included in a NixOS configuration and deployed to a (local or remote or virtual) machine.

Start new project with flake template

Before starting, follow the installation instructions.

An easy way to get started is to use the flake template provided by this project. Here's how to start a new project using the template:

1
2
3
4
5
mkdir myproject
cd myproject
nix flake init --template github:mlabs-haskell/cardano.nix
git init
git add .

Run a virtual machine

The default template provides a virtual machine configuration starting all the services in the preview testnet. Here's how to run it:

nix run .#vm

A virtual machine is started, with cardano-cli available to query the node:

cardano-cli query tip --testnet-magic 2

This machine is set up just like the one in Run a VM, but can be customized.

Look around

flake.nix

This Nix Flake is the entry point to the project. It locks inputs and provides the following inputs:

  • a NixOS configuration for the virtual machine, under nixosConfigurations.server-vm
  • an app to run the virtual machine as above, under apps.x86_64-linux.server-vm

preview.nix

This is the NixOS configuration to run cardano services for the machine.

vm.nix

This NixOS configuration sets virtual machine options such as cores, memory and port forwarding. It is included in the configuration for the nixosConfigurations.server-vm virtual machine in flake.nix.

Customize

To learn more, browse available NixOS options in nixpkgs and NixOS options provided by cardano.nix (see other modules in the menu on the left). You can ad these options to preview.nix to configure the system.

Deployment options

The configuration can be deployed to any target running NixOS, such as:

  • cloud hosts on AWS, DigitalOcean or any other cloud provider
  • physical machines
  • NixOS containers

There are a variety of resources to help install NixOS:

With a running NixOS installation and a NixOS configuration server in a nix flake, this command will deploy the server:

nixos-rebuild switch --flake .#server --target-host <target>