about summary refs log tree commit diff
path: root/users/wpcarro/nixos
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/nixos')
-rw-r--r--users/wpcarro/nixos/default.nix16
1 files changed, 15 insertions, 1 deletions
diff --git a/users/wpcarro/nixos/default.nix b/users/wpcarro/nixos/default.nix
index b1a878c95a07..e7ae5490b9b6 100644
--- a/users/wpcarro/nixos/default.nix
+++ b/users/wpcarro/nixos/default.nix
@@ -1,8 +1,22 @@
-{ depot, ... }:
+{ depot, pkgs, ... }:
 
 let systemFor = sys: (depot.ops.nixos.nixosFor sys).system;
 in {
   marcusSystem = systemFor depot.users.wpcarro.nixos.marcus;
+  deploy-diogenes = pkgs.writeShellScriptBin "deploy-diogenes" ''
+    set -euo pipefail
+    readonly TF_STATE_DIR=/depot/users/wpcarro/terraform
+    rm -f $TF_STATE_DIR/*.json
+    readonly STORE_PATH="$(nix-build /depot -A users.wpcarro.nixos.diogenes)"
+    cp $STORE_PATH $TF_STATE_DIR
+
+    function cleanup() {
+      rm -f "$TF_STATE_DIR/$(basename $STORE_PATH)"
+    }
+
+    trap cleanup EXIT
+    ${pkgs.terraform}/bin/terraform -chdir="$TF_STATE_DIR" apply
+  '';
 
   meta.targets = [ "marcusSystem" ];
 }