From f0b9d862a5e54fa7f9159636ce5a90ef3360231f Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 5 Feb 2021 11:34:05 +0100 Subject: pkgs/profpatsch: add deploy Small script to deploy my machines. --- pkgs/profpatsch/deploy.nix | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pkgs/profpatsch/deploy.nix (limited to 'pkgs/profpatsch/deploy.nix') 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 + ; +} -- cgit 1.4.1