~aasg/haunted-blog

ref: 06419c17297c3e7ce89ece9841f93b79e3a089f4 haunted-blog/.build.yml -rw-r--r-- 1.6 KiB
06419c17 — Aluísio Augusto Silva Gonçalves flake: Add a 'production' package 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# SPDX-FileCopyrightText: 2020 Aluísio Augusto Silva Gonçalves <https://aasg.name>
# SPDX-License-Identifier: MIT

image: nixos/latest
packages:
  - nixos.cachix
  - nixos.dnsutils
  - nixos.ipfs
  - nixos.ipfs-cluster
  - nixos.libarchive
  - nixos.nixUnstable
  - nixos.reuse
sources:
  - https://git.sr.ht/~aasg/haunted-blog
environment:
  job_name: haunted-blog
  cluster_address: /dnsaddr/c.ipfs.aasg.name
secrets:
  - cb717add-b052-4389-ba30-1fafaf9c79c7
  - 4e8ea133-31d9-499f-b45c-a20208be2838
tasks:
  - prepare: |
      # Enable flakes.
      mkdir -p ~/.config/nix
      echo 'experimental-features = nix-command flakes' >~/.config/nix/nix.conf
      # Haunt is not yet in Nixpkgs, so use our prebuilt derivation.
      cachix use aasg-nixexprs
  - check: |
      # Verify that the source is REUSE-compliant.
      reuse --root=haunted-blog lint
  - build: |
      nix build './haunted-blog#' --log-format raw-with-logs
  - package: |
      result=$(realpath result)
      bsdtar -caf ~/site.tar.zst --format=rpax --strip-components=3 "$result"
  - publish: |
      set -o pipefail
      shopt -s lastpipe
      export CLUSTER_CREDENTIALS

      result=$(realpath result)
      read -r CLUSTER_CREDENTIALS <~/.ipfs-cluster.key
      ipfs-cluster-ctl --host "$cluster_address" \
        add --quieter --recursive --name "$job_name-$JOB_ID" "$result" \
      | tee ~/cid | ipfs cid base32 | read -r cid

      nsupdate -vk ~/.nsupdate.conf <<NSUPDATE
        delete blog.dnslink.aasg.name TXT
        add blog.dnslink.aasg.name 300 TXT "dnslink=/ipfs/$cid"
        send
      NSUPDATE

      echo "Published to https://$cid.ipfs.dweb.link"
artifacts:
  - site.tar.zst
  - cid