{
  "path": "/3mbyw54q7gc22",
  "site": "at://did:plc:tbzfsowmg4zj234pws47u3x6/site.standard.publication/3mb25gdgmj22r",
  "tags": [
    "nix",
    "nixos",
    "ci/cd"
  ],
  "$type": "site.standard.document",
  "title": "Deploying my Blog to NixOS - Toolbox #4",
  "content": {
    "$type": "pub.leaflet.content",
    "pages": [
      {
        "id": "019b9a13-3d8c-700d-99d7-666d665eb99e",
        "$type": "pub.leaflet.pages.linearDocument",
        "blocks": [
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 189,
                    "byteStart": 178
                  },
                  "features": [
                    {
                      "uri": "https://leaflet.pub",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 274,
                    "byteStart": 257
                  },
                  "features": [
                    {
                      "uri": "https://mariuskimmina.com",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 438,
                    "byteStart": 421
                  },
                  "features": [
                    {
                      "uri": "https://github.com/mariuskimmina/leaflet-hugo-sync",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "Now I know most people think that a blog should be easy, you write something, you press publish and then it shows up online and I like that too - that's why I am writing this on leaflet.pub where it works exactly like this. But I also have my other page at mariuskimmina.com which is running on NixOS because.... reasons!\nAnd I want my posts that I write here on leaflet also to show up on my blog which is why I created leaflet-hugo-sync, a tool that fetches all your leaflet posts and converts them to markdown."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "Today I want to introduce you to the slightly overengineered way of how my leaflets end up on my page. This will involve no more then 3 repositories, easy peasy:"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.unorderedList",
              "children": [
                {
                  "$type": "pub.leaflet.blocks.unorderedList#listItem",
                  "content": {
                    "$type": "pub.leaflet.blocks.text",
                    "facets": [],
                    "plaintext": "leaflet-hugo-sync - the tool that converts leaflets to markdown"
                  },
                  "children": []
                },
                {
                  "$type": "pub.leaflet.blocks.unorderedList#listItem",
                  "content": {
                    "$type": "pub.leaflet.blocks.text",
                    "facets": [],
                    "plaintext": "homepage - my page created with hugo"
                  },
                  "children": []
                },
                {
                  "$type": "pub.leaflet.blocks.unorderedList#listItem",
                  "content": {
                    "$type": "pub.leaflet.blocks.text",
                    "facets": [],
                    "plaintext": "nix-hetzner-lab - the nix configuration of my server setup with nixos-anywhere"
                  },
                  "children": []
                }
              ]
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "I am still new to the nix world and if you have any ideas for improvements to this whole process then please let me know, my DMs are open on BlueSky."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 59,
                    "byteStart": 46
                  },
                  "features": [
                    {
                      "uri": "https://github.com/mariuskimmina/homepage",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 136,
                    "byteStart": 119
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                }
              ],
              "plaintext": "After I press publish on a Leaflet I go to my homepage repo on Github and I trigger a pipeline, this pipeline will run leaflet-hugo-sync and directly update the main branch of the repo. Once it finishes all my leaflets can be found as up to date markdown files in the repo."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 65,
                    "byteStart": 57
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                }
              ],
              "plaintext": "The following is the github actions code that runs on my homepage repo:"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.code",
              "language": "yaml",
              "plaintext": "name: Sync Leaflets\n\non:\n  workflow_dispatch:\n\njobs:\n  sync:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: write\n    steps:\n      - uses: actions/checkout@v4\n\n      - uses: DeterminateSystems/nix-installer-action@main\n      - uses: DeterminateSystems/magic-nix-cache-action@main\n\n      - name: Run leaflet-hugo-sync\n        run: nix run github:mariuskimmina/leaflet-hugo-sync\n\n      - name: Commit and push changes\n        run: |\n          git config user.name \"github-actions[bot]\"\n          git config user.email \"github-actions[bot]@users.noreply.github.com\"\n          git add content/ static/\n          if git diff --staged --quiet; then\n            echo \"No changes to commit\"\n          else\n            git commit -m \"sync: update leaflet posts\"\n            git push\n          fi\n\n      - name: Trigger nix-hetzner-lab deploy\n        if: success()\n        env:\n          GH_TOKEN: ${{ secrets.NIX_LAB_PAT }}\n        run: gh workflow run deploy.yml --repo mariuskimmina/nix-hetzner-lab"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "This is the only thing I need to trigger manually after publishing a leaflet. This steps takes ~1 Minute to complete."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.image",
              "image": {
                "$type": "blob",
                "ref": {
                  "$link": "bafkreiay73bogacnzg32xdtrmb32zfbgfc7casbvuqu7f6sx77xpe3sqg4"
                },
                "mimeType": "image/png",
                "size": 45062
              },
              "aspectRatio": {
                "width": 2258,
                "height": 133
              }
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 101,
                    "byteStart": 86
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 155,
                    "byteStart": 142
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                }
              ],
              "plaintext": "Once the main branch is updated it will trigger another github action that runs in my nix-hetzner-lab repository, which will essentially do a nixos-rebuild causing the updated version of the blog to be deployed."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.code",
              "language": "yaml",
              "plaintext": "name: Deploy\n\non:\n  workflow_dispatch:\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: write\n    steps:\n      - uses: actions/checkout@v4\n\n      - uses: DeterminateSystems/nix-installer-action@main\n      - uses: DeterminateSystems/magic-nix-cache-action@main\n\n      - name: Update flake\n        run: |\n          nix flake update homepage\n          git config user.name \"github-actions[bot]\"\n          git config user.email \"github-actions[bot]@users.noreply.github.com\"\n          git add flake.lock\n          if git diff --staged --quiet; then\n            echo \"No changes to flake.lock\"\n          else\n            git commit -m \"flake: update homepage\"\n            git push\n          fi\n\n      - name: Deploy\n        run: |\n          mkdir -p ~/.ssh\n          echo \"${{ secrets.DEPLOY_SSH_KEY }}\" > ~/.ssh/id_ed25519\n          chmod 600 ~/.ssh/id_ed25519\n          ssh-keyscan ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts\n          nix run nixpkgs#nixos-rebuild -- switch \\\n            --flake .#hetzner-lab \\\n            --target-host root@${{ secrets.SERVER_IP }}"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "Now this deploy jobs takes around ~12 minutes. If anyone sees a way to make this faster please let me know."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.image",
              "image": {
                "$type": "blob",
                "ref": {
                  "$link": "bafkreick5jylm7c56amlqkwd7jp4xzenaq6ualykl3etke6zm76pmzwzzm"
                },
                "mimeType": "image/png",
                "size": 40809
              },
              "aspectRatio": {
                "width": 2258,
                "height": 133
              }
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "But that's it, now the new updated version of the blog is running and my leaflet can be read on my hugo based homepage as well."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": ""
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "Find all my repos here:"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 41,
                    "byteStart": 0
                  },
                  "features": [
                    {
                      "uri": "https://github.com/mariuskimmina/homepage",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "https://github.com/mariuskimmina/homepage"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 48,
                    "byteStart": 0
                  },
                  "features": [
                    {
                      "uri": "https://github.com/mariuskimmina/nix-hetzner-lab",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "https://github.com/mariuskimmina/nix-hetzner-lab"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 50,
                    "byteStart": 0
                  },
                  "features": [
                    {
                      "uri": "https://github.com/mariuskimmina/leaflet-hugo-sync",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "https://github.com/mariuskimmina/leaflet-hugo-sync"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": ""
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "You can also find them on tangled"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 46,
                    "byteStart": 0
                  },
                  "features": [
                    {
                      "uri": "https://tangled.org/mariuskimmina.com/homepage",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "https://tangled.org/mariuskimmina.com/homepage"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 53,
                    "byteStart": 0
                  },
                  "features": [
                    {
                      "uri": "https://tangled.org/mariuskimmina.com/nix-hetzner-lab",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "https://tangled.org/mariuskimmina.com/nix-hetzner-lab"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 55,
                    "byteStart": 0
                  },
                  "features": [
                    {
                      "uri": "https://tangled.org/mariuskimmina.com/leaflet-hugo-sync",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "https://tangled.org/mariuskimmina.com/leaflet-hugo-sync"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": ""
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "I currently use github as the primary development hub because of github actions being available and free but I also plan to host a CI runner for tangled on my lab soon and then things might change."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [],
              "plaintext": "Hope you enjoyed this read and feel free to reach out to me with any feedback <3."
            }
          }
        ]
      }
    ]
  },
  "description": "you think having 3 repositories and NixOS involved in running a static website is ridiculous? Well, no, you are ridiculous!",
  "publishedAt": "2026-01-09T16:29:06.245Z"
}