diff --git a/.gitignore b/.gitignore
index 4088a6c..08e5933 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,9 @@
.nvimlog
.direnv/
-themes/
public/
result
+
+# ignore folders where we link in files from the nix store
+themes/
+static/font/
+static/style/fonts.css
\ No newline at end of file
diff --git a/config.toml b/config.toml
index 08fb453..46390a6 100644
--- a/config.toml
+++ b/config.toml
@@ -24,7 +24,7 @@ external_links_no_referrer = true
favicon = "/image/favicon.svg"
stylesheets = []
-use_cdn = true
+use_cdn = false
# include hashes for SRI
cdns = [
{ url = "https://cdn.jsdelivr.net/npm/firacode@6.2.0/distr/fira_code.min.css", hash = "sWIpcFPnJFfPqQU7FWn8H9+Xax/h5ihI8hVjQTBa5WmUde6CZZLw9DUAaIyA6j5u" },
diff --git a/content/posts/gitea-on-fly-io/fly-io-memory-dashboard.png b/content/posts/gitea-on-fly-io/fly-io-memory-dashboard.png
index bfe0ff9..0bbfa9c 100644
Binary files a/content/posts/gitea-on-fly-io/fly-io-memory-dashboard.png and b/content/posts/gitea-on-fly-io/fly-io-memory-dashboard.png differ
diff --git a/content/posts/gitea-on-fly-io/fly-io-scale-vm.png b/content/posts/gitea-on-fly-io/fly-io-scale-vm.png
index ed38e2c..8209337 100644
Binary files a/content/posts/gitea-on-fly-io/fly-io-scale-vm.png and b/content/posts/gitea-on-fly-io/fly-io-scale-vm.png differ
diff --git a/content/posts/gitea-on-fly-io/index.md b/content/posts/gitea-on-fly-io/index.md
index 28ca4bb..2c9d3c5 100644
--- a/content/posts/gitea-on-fly-io/index.md
+++ b/content/posts/gitea-on-fly-io/index.md
@@ -168,11 +168,17 @@ error: failed to push some refs to 'git.mat.services:mat/fly-apps.git'
Uh. Hm. I just got an email saying a Fly.io instance ran out of memory and crashed. Let's peek at our Fly.io dashboards:
-![Fly.io memory dashboard](fly-io-memory-dashboard.png)
+
That doesn't look so great. It seems like Gitea idles just under the amount of memory we have with a default instance size, and operations like `git push` can bump it over the threshold to an out-of-memory error. Let's check out the "Scale" section of the dashboard, and increase the memory allotment for this VM:
-![Fly.io VM scale interface](fly-io-scale-vm.png)
+
I have been running my Gitea install on a 512MB instance since the first day I started using it, which seems to be plenty of headroom for personal use. If you open up your Gitea installation to the public and it starts to get popular, you might end up needing to scale up further.
diff --git a/flake.nix b/flake.nix
index c2e456a..6e3a3cf 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,6 +6,7 @@
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
+ # theme
apollo.url = "github:not-matthias/apollo";
apollo.flake = false;
};
@@ -26,31 +27,53 @@
for image in content/**/_*.png static/image/**/_*.png; do
path=$(dirname $image)
file=$(basename $image)
- ${pkgs.pngquant}/bin/pngquant --quality 90-99 -f -o "$path/''${file:1}" $image
+ newimage=$path/''${file:1}
+ echo "optimizing $image"
+ ${pkgs.pngquant}/bin/pngquant --quality 80-90 -f -o $newimage $image
+ oldsize=$(stat --format=%s $image)
+ newsize=$(stat --format=%s $newimage)
+ pct=$(${pkgs.bc}/bin/bc <<< "scale=1; $newsize * 100 / $oldsize")
+ echo "size went from "$(($oldsize / 1024))"KB to "$(($newsize / 1024))"KB ("$pct"% as large as original)"
done
'';
+ inherit (pkgs.callPackage ./fonts.nix { }) copyFonts linkFonts;
in
{
- packages.default = pkgs.stdenv.mkDerivation {
- pname = "personal-site";
- version = "2022-08-13";
- src = ./.;
- nativeBuildInputs = with pkgs; [ optimize-images zola ];
- configurePhase = ''
- mkdir -p "themes/${themeName}"
- cp -r ${theme}/* "themes/${themeName}"
+ packages.default = with pkgs; stdenv.mkDerivation {
+ pname = "personal-site";
+ version = "2022-08-21";
+ src = ./.;
+ nativeBuildInputs = [ optimize-images zola ];
+ configurePhase = ''
+ mkdir -p themes/${themeName}
+ cp -r ${theme}/* themes/${themeName}
+ '' + copyFonts;
+ buildPhase = ''
optimize-images
- '';
- buildPhase = "zola build";
- installPhase = "cp -r public $out";
- };
+ zola build
+ '';
+ installPhase = "cp -r public $out";
+ };
devShells.default = with pkgs; mkShell {
- packages = [ optimize-images flyctl zola ];
- shellHook = ''
- mkdir -p themes
+ packages = [ flyctl optimize-images zola ];
+ shellHook = ''
+ mkdir -p themes
ln -snf "${theme}" "themes/${themeName}"
- '';
+ '' + linkFonts;
+ };
+ packages.docker =
+ let
+ site = self'.packages.default;
+ in
+ pkgs.dockerTools.buildLayeredImage {
+ name = site.pname;
+ tag = site.version;
+ contents = [ site pkgs.caddy ];
+
+ config = {
+ Cmd = [ "caddy" ];
+ };
+ };
};
- };
};
}
diff --git a/fonts.nix b/fonts.nix
new file mode 100644
index 0000000..b856a17
--- /dev/null
+++ b/fonts.nix
@@ -0,0 +1,122 @@
+{ fetchFromGitHub
+, lib
+, stdenv
+, woff2
+, writeShellScriptBin
+, writeText
+}:
+let
+ pathName = name: with lib; replaceStrings [ " " ] [ "-" ] (toLower name);
+in
+rec {
+ fontSrcs = [
+ {
+ name = "Inria Sans";
+ fileName = "InriaSans";
+ owner = "BlackFoundryCom";
+ repo = "InriaFonts";
+ rev = "v1.200";
+ path = "fonts/InriaSans/Web";
+ sha256 = "+YK03VnMXytTtHHgGYe2uARaTThaqrhpnhxPASBV9k0=";
+ cssVar = "header-font";
+ }
+ {
+ name = "iA Writer Quattro";
+ fileName = "iAWriterQuattroS";
+ owner = "iaolo";
+ repo = "iA-Fonts";
+ rev = "ba31f88a1e71f413f97bbd23a99e21b29d4c3a28";
+ path = "iA\ Writer\ Quattro/Webfonts";
+ sha256 = "8r06oRA+XA8mPjG3DJxzIVpaqptSqzraOWVvebbnMWE=";
+ cssVar = "text-font";
+ }
+ {
+ name = "IBM Plex Mono";
+ fileName = "IBMPlexMono";
+ owner = "IBM";
+ repo = "plex";
+ rev = "v6.1.0";
+ path = "IBM-Plex-Mono/fonts/complete/woff2";
+ sha256 = "SpH4+ldQJl58w5onxr7faDS6uVJKT8ZeLmE6712GFhw=";
+ cssVar = "code-font";
+ }
+ ];
+ fontDerivation = { name, owner, repo, rev, sha256, path, ... }: stdenv.mkDerivation {
+ name = "font-${pathName name}";
+ src = fetchFromGitHub {
+ inherit owner repo rev sha256;
+ sparseCheckout = path;
+ };
+ nativeBuildInputs = [ woff2 ];
+ buildPhase = ''
+ find . -name '*.ttf' -exec woff2_compress {} \;
+ '';
+ installPhase = ''
+ mkdir -p $out
+ find . -name '*.woff2' -exec cp {} $out \;
+ '';
+ };
+ fetchFont = fontSrc: {
+ inherit (fontSrc) name fileName cssVar;
+ font = fontDerivation fontSrc;
+ };
+ fonts = map fetchFont fontSrcs;
+ copyFont = { font, name, ... }: ''
+ mkdir -p static/font/${name}
+ cp -r ${font}/* static/font/${pathName name}
+ '';
+ linkFont = { font, name, ... }: ''
+ ln -snf "${font}" static/font/${pathName name}
+ '';
+ mkFontCss = { font, name, fileName, cssVar }:
+ let path = pathName name; in ''
+ @font-face {
+ font-family: '${name}';
+ font-style: normal;
+ font-weight: normal;
+ src: url('../font/${path}/${fileName}-Regular.woff2'), local('woff2');
+ font-display: swap;
+ }
+
+ @font-face {
+ font-family: '${name}';
+ font-style: normal;
+ font-weight: bold;
+ src: url('../font/${path}/${fileName}-Bold.woff2'), local('woff2');
+ font-display: swap;
+ }
+
+ @font-face {
+ font-family: '${name}';
+ font-style: italic;
+ font-weight: normal;
+ src: url('../font/${path}/${fileName}-Italic.woff2'), local('woff2');
+ font-display: swap;
+ }
+
+ @font-face {
+ font-family: '${name}';
+ font-style: italic;
+ font-weight: bold;
+ src: url('../font/${path}/${fileName}-BoldItalic.woff2'), local('woff2');
+ font-display: swap;
+ }
+
+ :root {
+ --${cssVar}: '${name}'
+ }
+
+ '';
+ fontCss = lib.concatMapStrings mkFontCss fonts;
+ fontCssFile = writeText "fonts.css" fontCss;
+ copyFonts = (lib.concatMapStrings copyFont fonts) + ''
+ mkdir -p static/style
+ cp ${fontCssFile} static/style/fonts.css
+ '';
+ linkFonts = ''
+ mkdir -p static/font
+ '' + (lib.concatMapStrings linkFont fonts) + ''
+ mkdir -p static/style
+ ln -sf ${fontCssFile} static/style/fonts.css
+ '';
+}
diff --git a/sass/style/main.scss b/sass/style/main.scss
index 3befa38..1e7ddd3 100644
--- a/sass/style/main.scss
+++ b/sass/style/main.scss
@@ -9,18 +9,7 @@
/* Used for: block comment, hr, ... */
--border-color: var(--bg-1);
- /* Fonts */
- --text-font: 'iA Writer Quattro';
- --header-font: 'Pretendard Std';
- --code-font: 'Fira Code';
-
- // Disabling variable fonts to bring site weight down
- // @supports(font-variation-settings: normal) {
- // /* Variable fonts */
- // --text-font: 'iA Writer Quattro var';
- // --header-font: 'Pretendard Std Variable';
- // --code-font: 'Fira Code VF';
- // }
+ // Fonts defined via fonts.nix
}
html {
diff --git a/static/image/_favicon.svg b/static/image/_favicon.svg
index b2fea0f..0b8de73 100644
--- a/static/image/_favicon.svg
+++ b/static/image/_favicon.svg
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/static/image/favicon.svg b/static/image/favicon.svg
index 5ef0732..3254ccc 100644
--- a/static/image/favicon.svg
+++ b/static/image/favicon.svg
@@ -12,7 +12,7 @@
-
+
diff --git a/templates/partials/header.html b/templates/partials/header.html
index 3472af4..5760df1 100644
--- a/templates/partials/header.html
+++ b/templates/partials/header.html
@@ -42,7 +42,6 @@
-
{% if config.extra.stylesheets %}
{% for stylesheet in config.extra.stylesheets %}