From fb0c5b82e8b34b38c83a0d3d720d88d4f1f2f5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natalie=20Klestrup=20R=C3=B6ijezon?= Date: Tue, 8 Apr 2025 00:10:36 +0200 Subject: [PATCH 1/3] Document per-host SSH connection options --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index de9ebdf..300ee48 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,11 @@ By passing `--allow-build-shell` and setting `network.buildShell` to a nix-shell `substituteOnDestination` Sets the `--substitute-on-destination` flag on nix copy, allowing for the deployment target to use substitutes. See `nix copy --help`. (default: false) +`deployment.targetHost` makes morph connect to the host on a different hostname. (default: the attribute name) + +`deployment.targetPort` makes morph connect to the host on a different SSH port. (default: ssh's default, 22 unless overridden) + +`deployment.targetUser` makes morph connect to the host as a different SSH user. (default: `SSH_USER` environment variable, ssh configuration, or your local username) Example usage of `nixConfig` and deployment module options: ``` @@ -210,6 +215,9 @@ machine1 = { ... }: { machine2 = { ... }: { deployment.substituteOnDestination = true; + deployment.targetHost = "10.0.0.5"; + deployment.targetPort = 2222; + deployment.targetUser = "admin"; }; ``` From d925bf2973c5acad71aa3e13aa3f4188764e58ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natalie=20Klestrup=20R=C3=B6ijezon?= Date: Tue, 8 Apr 2025 00:18:06 +0200 Subject: [PATCH 2/3] Document `defaults` --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 300ee48..06582fb 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,34 @@ The default is an empty set, meaning that the nix configuration is inherited fro **network.buildShell** By passing `--allow-build-shell` and setting `network.buildShell` to a nix-shell compatible derivation (eg. `pkgs.mkShell ...`), it's possible to make morph execute builds from within the defined shell. This makes it possible to have arbitrary dependencies available during the build, say for use with nix build hooks. Be aware that the shell can potentially execute any command on the local system. +**defaults** +The special `defaults` pseudo-host will be merged into all other hosts, rather than deployed on its own. + +For example, this: + +```nix +{ + defaults = { pkgs, ... }: { + environment.systemPackages = [ pkgs.curl ]; + }; + machine1 = {}; + machine2 = {}; +} +``` + +Is equivalent to this: + +```nix +{ + machine1 = { pkgs, ... }: { + environment.systemPackages = [ pkgs.curl ]; + }; + machine2 = { pkgs, ... }: { + environment.systemPackages = [ pkgs.curl ]; + }; +} +``` + **special deployment options:** (per-host granularity) From f1b042095b44c666d9cd864a9de5216e05d340b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natalie=20Klestrup=20R=C3=B6ijezon?= Date: Tue, 8 Apr 2025 00:19:00 +0200 Subject: [PATCH 3/3] Enable syntax highlighting for the Nix code blocks in the README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06582fb..57705b7 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ Is equivalent to this: `deployment.targetUser` makes morph connect to the host as a different SSH user. (default: `SSH_USER` environment variable, ssh configuration, or your local username) Example usage of `nixConfig` and deployment module options: -``` +```nix network = { nixConfig = { "extra-sandbox-paths" = "/foo/bar"; @@ -252,7 +252,7 @@ machine2 = { ... }: { **mutually recursive configurations** Each host's configuration has access to a `nodes` argument, which contains the compiled configurations of all hosts. -``` +```nix machine1 = { nodes, ... }: { hostnames.machine2 = (builtins.head nodes.machine2.networking.interfaces.foo.ipv4.addresses).address;