2021-10-20 15:49:11 +02:00
|
|
|
args@{ pkgs, depot, ... }:
|
2020-06-16 04:24:13 +02:00
|
|
|
with pkgs;
|
2020-06-16 02:44:06 +02:00
|
|
|
let
|
2020-06-16 04:24:13 +02:00
|
|
|
site = import ./site.nix args;
|
2020-11-16 17:01:28 +01:00
|
|
|
resume = import ../resume args;
|
2020-06-16 02:44:06 +02:00
|
|
|
bucket = "s3://gws.fyi";
|
|
|
|
distributionID = "E2ST43JNBH8C64";
|
2021-03-29 01:51:20 +02:00
|
|
|
|
|
|
|
css = runCommand "main.css"
|
|
|
|
{
|
|
|
|
buildInputs = [ pkgs.minify ];
|
|
|
|
} ''
|
|
|
|
minify --type css < ${./main.css} > $out
|
|
|
|
'';
|
|
|
|
|
2021-10-20 15:49:11 +02:00
|
|
|
keys = runCommand "ssh-keys" { } ''
|
|
|
|
touch $out
|
|
|
|
echo "${depot.users.grfn.keys.main}" >> $out
|
|
|
|
'';
|
|
|
|
|
2020-06-16 02:44:06 +02:00
|
|
|
website =
|
|
|
|
runCommand "gws.fyi" { } ''
|
|
|
|
mkdir -p $out
|
2021-03-29 01:51:20 +02:00
|
|
|
cp ${css} $out/main.css
|
2020-06-16 04:24:13 +02:00
|
|
|
cp ${site.index} $out/index.html
|
2021-08-18 04:17:39 +02:00
|
|
|
cp -r ${site.recipes} $out/recipes
|
2020-11-16 17:01:28 +01:00
|
|
|
cp ${resume} $out/resume.pdf
|
2021-10-20 15:49:11 +02:00
|
|
|
cp ${keys} $out/keys
|
2023-11-13 20:24:19 +01:00
|
|
|
cp ${./pubkey.gpg} $out/pubkey.gpg
|
2020-06-16 02:44:06 +02:00
|
|
|
'';
|
2020-06-16 04:24:13 +02:00
|
|
|
|
2023-11-06 22:02:43 +01:00
|
|
|
purge-cf = writeShellApplication {
|
|
|
|
name = "purge-cf.sh";
|
|
|
|
runtimeInputs = [ httpie jq pass ];
|
|
|
|
text = ''
|
|
|
|
cfapi() {
|
|
|
|
http \
|
|
|
|
"https://api.cloudflare.com/client/v4/$1" \
|
|
|
|
X-Auth-Email:root@gws.fyi \
|
|
|
|
"X-Auth-Key: $(pass cloudflare-api-key)" \
|
|
|
|
"''${@:2}"
|
|
|
|
}
|
|
|
|
|
|
|
|
zone_id=$(
|
|
|
|
cfapi zones \
|
|
|
|
| jq -r '.result[] | select(.name == "gws.fyi") | .id'
|
|
|
|
)
|
|
|
|
|
|
|
|
cfapi "zones/$zone_id/purge_cache" purge_everything:=true
|
|
|
|
'';
|
|
|
|
};
|
2021-03-29 01:54:26 +02:00
|
|
|
in
|
2023-11-06 22:02:43 +01:00
|
|
|
(writeShellApplication {
|
|
|
|
name = "deploy.sh";
|
|
|
|
runtimeInputs = [ awscli2 ];
|
|
|
|
text = ''
|
|
|
|
aws --profile personal s3 sync ${website}/ ${bucket}
|
|
|
|
echo "Deployed to http://gws.fyi"
|
|
|
|
'';
|
|
|
|
}).overrideAttrs {
|
|
|
|
passthru = { inherit website site purge-cf; };
|
2021-03-29 01:54:26 +02:00
|
|
|
}
|