Load existing code on a new server

The Load existing code on a new server option is for when you already have code you wish to ship on Shipnix.

There are two supported use-cases.

1. Import a project that already works with Shipnix

When you already have a nixos folder and a flake.nix in your project root that works with Shipnix, this is the alternative for you.

After provisioning the “Load existing code” server, do the following:

  1. In your code, make sure you have a NixOS configuration that corresponds with your server name given by Shipnix.

Note that the name text-server-two needs to be present

{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
};
outputs =
{ self
, nixpkgs
, nixpkgs-unstable
} @attrs:
let
...
in
{
nixosConfigurations."test-server-one" = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = attrs // {
environment = "production";
};
modules = [
# Overlays-module makes "pkgs.unstable" available in configuration.nix
({ config, pkgs, ... }: {
nixpkgs.overlays = [ overlay-unstable ];
})
./nixos/configuration.nix
];
};
+ nixosConfigurations."test-server-two" = nixpkgs.lib.nixosSystem {
+ inherit system;
+ specialArgs = attrs // {
+ environment = "stage";
+ };
+ modules = [
+ # Overlays-module makes "pkgs.unstable" available in configuration.nix
+ ({ config, pkgs, ... }: {
+ nixpkgs.overlays = [ overlay-unstable ];
+ })
+ ./nixos/configuration.nix
+ ];
+ };
+ };

}
  1. Select your preset so Shipnix can make as good preparations as possible for provisioning (binary caches, databases etc)
  2. Follow the guide to add Git and deploy keys
  3. Check your environment variables and make sure they are correct
  4. Deploy

If something went wrong, just adjust accordingly and try again.

2. Shipnixify a project without Shipnix config

You can turn a non-Shipnix project into a Shipnix project with a bit of additional work.

After provisioning the server, do the following:

  1. Select your preset so Shipnix can make as good preparations as possible for provisioning (binary caches, databases etc)
  2. Click Generate shipnixifier
  3. Follow the instruction on your local machine to add the generated Shipnix config
  4. Follow the guide to add Git and deploy keys
  5. Check your environment variables and make sure they are correct
  6. Deploy