Documentation

menu
Nix FlakesHostingIntroductionBranch HostingPull-request DeploymentsSecretsPersistenceDebuggingMultiple ServersCustom DomainsExample: Typescript & GoExample: JitsiExample: RSS BridgeExample: Tiny Tiny RSSExample: SearxGarnyaml configWhat Garnix CI doesUsing Private InputsCachingGitHub Actions IntegrationBadges

Branch hostingshare

garnix can host NixOS configurations from the latest commit of a specified branch. To enable this feature, simply add a servers section to your garnix.yaml (create a garnix.yaml if you don't yet have one). For example, if you want your deployment to track the branch prod, and the NixOS configuration is called myMachine in flake.nix, you would write:

servers:
  - configuration: myMachine
    deployment:
      type: on-branch
      branch: prod

Additionally, your nixos configuration must have the following items:

  fileSystems."/" = {
    device = "/dev/sda1";
    fsType = "ext4";
  };
  boot.loader.grub.device = "/dev/sda";

If you don't need any secrets in your deployment, that's all there is to it! You can access your machines via URLs that follow this scheme:

<hostname>.<branch>.<myrepo>.<myorg/myuser>.garnix.me

Where hostname is the name of the nixosConfiguration. Whenever there is a new commit, garnix will spin up a new VPS with the new configuration, wait until it's ready, then reroute the traffic to the new machine atomically, and delete the old one.

Note that currently only port 80 is available via the garnix.me URL. If you need other ports – to e.g. SSH into the machine – use the IP address, which you get after each deploy.