about summary refs log tree commit diff
path: root/users/sterni/machines/default.nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2023-11-30T17·40+0100
committersterni <sternenseemann@systemli.org>2023-11-30T21·27+0000
commit77b990b0b226dfef7c15385a59fffdb48e87e9da (patch)
tree27b7a60b61c8c432cb1f425a4c02789e825f3931 /users/sterni/machines/default.nix
parent6a5faac11d77f1a3aef3214d04f64f593ac52e72 (diff)
feat(sterni/machines): prevent deploy if hostname doesn't match r/7096
Change-Id: I5a850e0d98069483e89d90022b624feba60ceebc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10179
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/machines/default.nix')
-rw-r--r--users/sterni/machines/default.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/users/sterni/machines/default.nix b/users/sterni/machines/default.nix
index 4a859a337a22..291d9756c7e3 100644
--- a/users/sterni/machines/default.nix
+++ b/users/sterni/machines/default.nix
@@ -10,9 +10,13 @@ let
     (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./.));
 
   # TODO(sterni): share code with rebuild-system
-  localDeployScriptFor = { system, ... }:
+  localDeployScriptFor = { system, config, ... }:
     pkgs.writeShellScript "local-deploy-${system.name}" ''
       set -eu
+      if [[ "$(hostname)" != "${config.networking.hostName}" ]]; then
+        echo "$0: unexpected hostname: $(hostname). Are you deploying on the right machine?"
+        exit 1
+      fi
       nix-env -p /nix/var/nix/profiles/system --set "${system}"
       "${system}/bin/switch-to-configuration" switch
     '';