about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-02-05 11:34:05 +0100
committerProfpatsch <mail@profpatsch.de>2021-02-05 11:34:05 +0100
commitf0b9d862a5e54fa7f9159636ce5a90ef3360231f (patch)
tree6bc6f953851d1b86614e65c37fb2db490d112312 /pkgs
parent035f7e860957e8c5637bdd1c033c1953dce980b3 (diff)
pkgs/profpatsch: add deploy
Small script to deploy my machines.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/profpatsch/default.nix4
-rw-r--r--pkgs/profpatsch/deploy.nix36
2 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/profpatsch/default.nix b/pkgs/profpatsch/default.nix
index 774d6a9c..ed1bc427 100644
--- a/pkgs/profpatsch/default.nix
+++ b/pkgs/profpatsch/default.nix
@@ -119,6 +119,10 @@ in rec {
     readGitignoreFile
     ;
 
+  inherit (import ./deploy.nix { inherit pkgs getBins; })
+    deploy
+    ;
+
   backlight = callPackage ./backlight { inherit (pkgs.xorg) xbacklight; };
   display-infos = callPackage ./display-infos { inherit sfttime; };
   git-commit-index = callPackage ./git-commit-index { inherit script; };
diff --git a/pkgs/profpatsch/deploy.nix b/pkgs/profpatsch/deploy.nix
new file mode 100644
index 00000000..c85ef45e
--- /dev/null
+++ b/pkgs/profpatsch/deploy.nix
@@ -0,0 +1,36 @@
+# The only deployment tool that anybody should take seriously
+{ pkgs, getBins }:
+
+let
+  bins = getBins pkgs.coreutils [ "realpath" ]
+      // getBins pkgs.openssh [ "ssh" ]
+      // getBins pkgs.nix [ "nix-build" "nix-copy-closure" ]
+      ;
+
+  deploy = pkgs.writers.writeDash "deploy-machine-profpatsch" ''
+    set -e
+    MACHINE="''${1?please set machine as first argument}"
+    OUT_LINK="system-$MACHINE"
+
+    ${bins.nix-build} \
+      --show-trace \
+      --out-link "$OUT_LINK" \
+      -I "nixpkgs=$HOME/nixpkgs" \
+      -A "machines.profpatsch.$MACHINE.build" \
+      "$HOME/vuizvui"
+
+    ${bins.nix-copy-closure} \
+      --to "ssh://$MACHINE?compress=true" \
+      "$OUT_LINK"
+
+    ${bins.ssh} \
+      "root@$MACHINE" \
+      "$(${bins.realpath} $OUT_LINK)/bin/switch-to-configuration" \
+      "switch"
+  '';
+
+in {
+  inherit
+    deploy
+    ;
+}