blob: 51058fcc31d29a91e641515c5130e02c040005f0 [file] [log] [blame]
Samuel Shuertc6f63032024-12-31 11:09:23 -05001# SPDX-FileCopyrightText: 2024 Clicks Codes
2#
3# SPDX-License-Identifier: GPL-3.0-only
4
5{ config, inputs, lib, system, pkgs, ... }:
6let
7 siteUrl = "a.starrysky.blog";
8 blogTitle = "A Starry Blog";
9 publicTitleRegex = ''(M36\.31\+[0-9]+ )?(?<title>.*)'';
10 blogPath = "/persist/data/var/lib/silverbullet/Skyler Grey/M36 Personal/30-39 Creativity/31 Blog";
11in
12{
13 options.clicks.sites."${siteUrl}".enable = lib.options.mkEnableOption "Enable hosting https://${siteUrl}";
14
15 config = lib.modules.mkIf config.clicks.sites."${siteUrl}".enable {
16 clicks.services.nginx = {
17 enable = true;
18
19 hosts.${siteUrl} = {
20 service = lib.clicks.nginx.http.directory "/var/lib/whisk/${siteUrl}";
21 www = false;
22 enableHttp = true;
23 };
24 };
25
26 environment.systemPackages = [ pkgs.nodejs-slim_23 ];
27
28 systemd.services."${siteUrl}-setup" = {
29 script = ''
30 export PATH=${pkgs.nodejs-slim_23}/bin:${pkgs.pnpm}/bin::$PATH
31 WORKDIR=$(mktemp -d)
32 cp -r ${inputs.whisk}/frontend/* $WORKDIR
33 cd $WORKDIR
34 pnpm i --reporter=append-only
35
36 mkdir -p /var/lib/whisk
37 rm -rf /var/lib/whisk/${siteUrl}
38
39 export BLOG_PATH='${blogPath}'
40 export PUBLIC_TITLE_REGEX='${publicTitleRegex}'
41 export SITE_URL='${siteUrl}'
42 export BLOG_TITLE='${blogTitle}'
43
44 echo $BLOG_PATH
45
46 pnpm run build --outDir /var/lib/whisk/${siteUrl}
47 '';
48
49 serviceConfig.Type = "oneshot";
50
51 path = [ pkgs.nodejs-slim_23 pkgs.pnpm ];
52
53 wantedBy = [ "nginx.service" ];
54 before = [ "nginx.service" ];
55 };
56 };
57}