From c3f2c548a6adfa0cbb4c915433cde736e2c5fad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 12 Apr 2024 16:37:50 +0200 Subject: [PATCH] add deploy script for homepage --- docs/deploy-docs.nix | 35 +++++++++++++++++++++++++++++++++++ docs/flake-module.nix | 8 +++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 docs/deploy-docs.nix diff --git a/docs/deploy-docs.nix b/docs/deploy-docs.nix new file mode 100644 index 000000000..a03176cbf --- /dev/null +++ b/docs/deploy-docs.nix @@ -0,0 +1,35 @@ +{ + writeShellScriptBin, + coreutils, + openssh, + rsync, + lib, + docs, +}: + +writeShellScriptBin "deploy-docs" '' + export PATH="${ + lib.makeBinPath [ + coreutils + openssh + rsync + ] + }" + + if [ -n "$SSH_HOMEPAGE_KEY" ]; then + echo "$SSH_HOMEPAGE_KEY" > ./ssh_key + chmod 600 ./ssh_key + sshExtraArgs="-i ./ssh_key" + else + sshExtraArgs= + fi + + rsync \ + -e "ssh -o StrictHostKeyChecking=no $sshExtraArgs" \ + -a ${docs}/ \ + www@clan.lol:/var/www/docs.clan.lol + + if [ -e ./ssh_key ]; then + rm ./ssh_key + fi +'' diff --git a/docs/flake-module.nix b/docs/flake-module.nix index eabb1498e..13e5990a1 100644 --- a/docs/flake-module.nix +++ b/docs/flake-module.nix @@ -1,11 +1,17 @@ { inputs, ... }: { perSystem = - { self', pkgs, ... }: + { + config, + self', + pkgs, + ... + }: { devShells.docs = pkgs.callPackage ./shell.nix { inherit (self'.packages) docs; }; packages = { docs = pkgs.python3.pkgs.callPackage ./default.nix { inherit (inputs) nixpkgs; }; + deploy-docs = pkgs.callPackage ./deploy-docs.nix { inherit (config.packages) docs; }; }; }; }