Documentation

menu
HostingIntroductionBranch HostingPull-request DeploymentsSecretsPersistenceDebuggingMultiple ServersCustom DomainsExample: Typescript & GoExample: JitsiExample: RSS BridgeExample: Tiny Tiny RSSExample: SearxActionsInstalling Nixyaml configNix FlakesWhat Garnix CI doesIncremental BuildsUsing Private InputsCachingEnterprise installationsGitHub Actions IntegrationBadgesGarnModulesNodejsHaskellRustPostgreSQLUseropen source

Multiple serversshare

garnix gives each version of each server it's own unique URL, based on the hash of the NixOS configuration. This makes zero-downtime deployments much easier, and has a number of other benefits. (You can read more about this idea in our blog post.)

The correct way to reference one server from another is by this URL. As a helper, you can use the lib.getHashSubdomain function from garnix-lib. For example:

{
  ...
  inputs.garnix-lib.url = "github:garnix-io/garnix-lib";

  outputs = { self, nixpkgs, garnix-lib, ... }: {
    nixosConfigurations.machine1 = ...;
    nixosConfigurations.machine2 = nixpkgs.lib.nixosSystem {
      ...
      modules = [{
        ...
        myservice.otherServiceURL =
          "http://" +
          garnix-lib.lib.getHashSubdomain self.nixosConfigurations.machine1 +
          "/somepath";
      }]

    }
  }
}