This module provides a declarative interface for defining deploy-rs nodes
directly inside host files.
It replaces the traditional deploy-rs configuration with a cleaner,
per-host DSL that integrates automatically into the flake.
- Allow each host to declare its own deployment targets
- Avoid editing
flake.nixwhen adding new servers - Support multiple deployment profiles per host
- Provide a consistent structure for remote activation
The flake collects all deployment definitions and generates:
deploy.nodes {...}This enables multi-node deployments from a single flake.
A deployment entry has the following shape:
deployment.<node> = {
hostname = "example.com";
fastConnection = false;
profiles.system = {
sshUser = "admin";
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.<host>;
};
};<node>is the name used by deploy-rs<host>is the NixOS configuration to deploy
Remote host address or IP.
Optimizes SSH settings for low-latency connections.
Defaults to false.
User used for SSH connection.
User used for activation on the remote machine.
Activation package generated by deploy-rs.
This is typically:
deploy-rs.lib.${system}.activate.nixos self.nixosConfigurations.<host>- Each host may define zero or more
deployment.<node>entries. - The flake collects all of them.
- The structure is flattened.
- The result becomes:
deploy.nodes = {
<node1> = { ... };
<node2> = { ... };
...
};This means:
- You can deploy any host without editing the flake.
- Multiple hosts can define multiple nodes.
- Nodes can have multiple profiles.
{pkgs, ...}: {
# ... other host configurations ...
deployment.myServer = {
hostname = "0.0.0.0";
profiles.system = {
sshUser = "admin";
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.myServer;
};
};
# ... other host configurations ...
}{pkgs, ...}: {
# ... other host configurations ...
deployment.edge = {
hostname = "edge.example.com";
profiles.system = {
sshUser = "admin";
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.edge;
};
profiles.backup = {
sshUser = "backup";
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.edge;
};
};
# ... other host configurations ...
}The deploy-migration.sh script relies on this module:
- It reads
deploy.nodes.<node>.hostname - It reads
deploy.nodes.<node>.profiles.system.sshUser - It reads the activation path
- This module is therefore required for:
- deploy-migration
- remote PostgreSQL-safe deployments
Use it when:
- A host needs remote deployment
- You want declarative deploy-rs configuration
- You want to avoid editing the flake
Do not use it for:
- local rebuilds
- non-NixOS targets
- ad-hoc SSH commands