| # SPDX-FileCopyrightText: 2024 Clicks Codes |
| # |
| # SPDX-License-Identifier: GPL-3.0-only |
| |
| { config, inputs, lib, system, pkgs, ... }: |
| let |
| siteUrl = "a.starrysky.blog"; |
| blogTitle = "A Starry Blog"; |
| publicTitleRegex = ''(M36\.31\+[0-9]+ )?(?<title>.*)''; |
| blogPath = "/persist/data/var/lib/silverbullet/Skyler Grey/M36 Personal/30-39 Creativity/31 Blog"; |
| in |
| { |
| options.clicks.sites."${siteUrl}".enable = lib.options.mkEnableOption "Enable hosting https://${siteUrl}"; |
| |
| config = lib.modules.mkIf config.clicks.sites."${siteUrl}".enable { |
| clicks.services.nginx = { |
| enable = true; |
| |
| hosts.${siteUrl} = { |
| service = lib.clicks.nginx.http.directory "/var/lib/whisk/${siteUrl}"; |
| www = false; |
| enableHttp = true; |
| }; |
| }; |
| |
| environment.systemPackages = [ pkgs.nodejs-slim_23 ]; |
| |
| systemd.services."${siteUrl}-setup" = { |
| script = '' |
| export PATH=${pkgs.nodejs-slim_23}/bin:${pkgs.pnpm}/bin::$PATH |
| WORKDIR=$(mktemp -d) |
| cp -r ${inputs.whisk}/frontend/* $WORKDIR |
| cd $WORKDIR |
| pnpm i --reporter=append-only |
| |
| mkdir -p /var/lib/whisk |
| rm -rf /var/lib/whisk/${siteUrl} |
| |
| export BLOG_PATH='${blogPath}' |
| export PUBLIC_TITLE_REGEX='${publicTitleRegex}' |
| export SITE_URL='${siteUrl}' |
| export BLOG_TITLE='${blogTitle}' |
| |
| echo $BLOG_PATH |
| |
| pnpm run build --outDir /var/lib/whisk/${siteUrl} |
| ''; |
| |
| serviceConfig.Type = "oneshot"; |
| |
| path = [ pkgs.nodejs-slim_23 pkgs.pnpm ]; |
| |
| wantedBy = [ "nginx.service" ]; |
| before = [ "nginx.service" ]; |
| }; |
| }; |
| } |