Compare commits
119 Commits
f2bb36b862
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 098bc74008 | |||
| a6e9a2498f | |||
| 41fea82c93 | |||
| ce09d9d7a4 | |||
| eed8febf6e | |||
| cbe766ea2d | |||
| 1f3a8b9447 | |||
| 386062a6a6 | |||
| dc96021ba1 | |||
| 7814ee7ae2 | |||
| 4febf06c5c | |||
| c5f6c4a8fa | |||
| 37d5bac9d0 | |||
| ef8369e26a | |||
| d25e8219f2 | |||
| b0ca0f3916 | |||
| 6b4208003c | |||
| 15af4fd7cb | |||
| 5243e4dffd | |||
| 0b5e18dc74 | |||
| 03aa7ab07a | |||
| 479c5bccae | |||
| 57186ed3b4 | |||
| 582566cc33 | |||
| 86b8966290 | |||
| fe2a356510 | |||
| 96ff06fd8b | |||
| 90e4e35230 | |||
| fc1d8d5a86 | |||
| 338ff7540c | |||
| 0d3ac91a55 | |||
| b41d106186 | |||
| cc79adb0d2 | |||
| dd5f160246 | |||
| 08246ed696 | |||
| 4001c236f2 | |||
| 68406e3947 | |||
| 8546a16acd | |||
| c32e922940 | |||
| eb1710b902 | |||
| d4d627889a | |||
| 507a8fa0ea | |||
| 0ebeb2f4ff | |||
| 3ccd612c87 | |||
| e80bb5010e | |||
| 9ea34ddf5f | |||
| 6ad81dae17 | |||
| 1af36f4ab9 | |||
| fcedeaaa87 | |||
| dea14d236b | |||
| 9c7ad6ea08 | |||
| be048c72c6 | |||
| cf1f1c0776 | |||
| eb06a6fd72 | |||
| cbaeda55b2 | |||
| d3a47f1884 | |||
| 16c4df9a0d | |||
| 7dfca96a92 | |||
| ddef357a6a | |||
| f6641f5296 | |||
| 335ee2545b | |||
| 1e7a0a28b0 | |||
| ec6028dd82 | |||
| 1f62373017 | |||
| 2dc96c08f4 | |||
| 77b550fe48 | |||
| f992d6e1c8 | |||
| 77d55f643c | |||
| fc7b2c415a | |||
| 1dcdd8b5f8 | |||
| 43119e7f5f | |||
| a571954c4d | |||
| 25e7e4f2aa | |||
| 71c0347943 | |||
| 1306acdd21 | |||
| d7f1c91a05 | |||
| a55ea19a98 | |||
| b87f5c8b5a | |||
| 61315cf94a | |||
| 694d2fac14 | |||
| feea668396 | |||
| 850ddce3b9 | |||
| 9adf19a79e | |||
| 7d6f362936 | |||
| f5c1772de0 | |||
| 0962df69ad | |||
| 2a86640401 | |||
| fda466a8cf | |||
| ee116b138f | |||
| abba267fec | |||
| 7a1eb96fcc | |||
| 3d74e6f5a2 | |||
| 7dad80f44d | |||
| 9ea42f306b | |||
| 1c3436fdc3 | |||
| 6b8fa513b4 | |||
| c1283b0165 | |||
| 9b64a99074 | |||
| 76e8f1c998 | |||
| abb2e1da3b | |||
| 782c9ed45a | |||
| df95db0f2d | |||
| 1216263fd8 | |||
| f704ceda8d | |||
| aebf198ca8 | |||
| ab4b92d031 | |||
| 211237d9be | |||
| d44e5fc12f | |||
| d065ca364e | |||
| 1b7cf307db | |||
| 65efe9d60b | |||
| aec571a4a5 | |||
| 85373a73b0 | |||
| e7615c4947 | |||
| 29e03c2732 | |||
| 1c0c7355c1 | |||
| 0f22123471 | |||
| 67b47d9c29 | |||
| 29c6c9bcba |
@@ -1,18 +1,48 @@
|
||||
source $stdenv/setup
|
||||
|
||||
# Set up Ruby to use UTF-8
|
||||
export RUBYOPT="-KU -E utf-8:utf-8"
|
||||
|
||||
# Copy files to a mutable directory.
|
||||
cp -r $src/* .
|
||||
# We'll generate some static files so make static writable
|
||||
# We also store the code HTML files alongside Agda code, so make 'code' writable too
|
||||
mkdir -p static && chmod -R u+w static code
|
||||
|
||||
# Hugo can't set baseUrl via CLI for multi-lingual hosts.
|
||||
# We have to manually edit the configuration.
|
||||
sed -i "$urlSub" config.toml
|
||||
# We host some static files (KaTeX CSS in production) on
|
||||
# static.danilafe.com. However, we can just bundle them here instead!
|
||||
# Configure Hugo to do so by writing the expected final paths to config-urls.toml
|
||||
echo '[params]' >> config-urls.toml
|
||||
echo 'katexCssUrl = "/katex/katex.min.css"' >> config-urls.toml
|
||||
echo 'normalizeCssUrl = "/normalize/normalize.css"' >> config-urls.toml
|
||||
echo 'visNetworkJsUrl = "/vis-network/vis-network.min.js"' >> config-urls.toml
|
||||
echo 'bergamotJsUrl = "/bergamot/bergamot.js"' >> config-urls.toml
|
||||
echo 'katexJsUrl = "/katex/katex.min.js"' >> config-urls.toml
|
||||
echo 'resumeStaticFile = "/Resume-Danila-Fedorin.pdf"' >> config-urls.toml
|
||||
|
||||
# Build site with Hugo
|
||||
hugo $extraFlags
|
||||
hugo $hugoFlags --config=config.toml,config-urls.toml
|
||||
|
||||
# Create/copy generated files
|
||||
# Can't do submodules because nix flake inputs get their .git deleted
|
||||
mkdir -p static/graph && ruby ./analyze.rb > static/graph/graph.gen.js # Graph files
|
||||
stork build --input public/index.toml --output static/index.st # Search index
|
||||
cp $resume/Resume-Danila-Fedorin.pdf static/Resume-Danila-Fedorin.pdf
|
||||
cp -r $webFiles/* static/
|
||||
cp -r $agdaHtml/* code/
|
||||
|
||||
# Static folder changed, re-run Hugo
|
||||
hugo $hugoFlags --config=config.toml,config-urls.toml
|
||||
|
||||
# Do post-processing of HTML files: render math, link up Agda code, subset fonts and icons
|
||||
gendir="public/$publicPath"
|
||||
htmlfiles=$(find $gendir/ -regex "$gendir/.*\.html")
|
||||
chmod -R u+w $gendir
|
||||
echo $htmlfiles | xargs ${gems}/bin/bundle exec ${ruby}/bin/ruby ./convert.rb --katex-js-file static/katex/katex.min.js
|
||||
echo $htmlfiles | xargs ${gems}/bin/bundle exec ${ruby}/bin/ruby ./agda.rb
|
||||
echo $htmlfiles | xargs ${gems}/bin/bundle exec ${ruby}/bin/ruby ./chatgpt-subset-feather-icon.rb $gendir/feather-sprite.svg
|
||||
echo $htmlfiles | xargs python3 chatgpt-subset-one-go.py $gendir/fonts
|
||||
|
||||
# Output result
|
||||
mkdir $out
|
||||
cp -r public/$publicPath/* $out/
|
||||
|
||||
# Render math in HTML and XML files.
|
||||
find $out/ -regex "$out/.*\.html" | xargs katex-html
|
||||
cp -r $gendir/* $out/
|
||||
|
||||
258
flake.lock
generated
258
flake.lock
generated
@@ -1,13 +1,36 @@
|
||||
{
|
||||
"nodes": {
|
||||
"bergamot-elm": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": [
|
||||
"web-files",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1766788208,
|
||||
"narHash": "sha256-/P3uz+VNeNOFzI2qSIijy53MpnejO1sWgB+gMqcI2z0=",
|
||||
"ref": "main",
|
||||
"rev": "ceca48840efe668fb033b47bc6e415ea4cf9ae85",
|
||||
"revCount": 97,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Everything-I-Know-About-Types/bergamot-elm.git"
|
||||
},
|
||||
"original": {
|
||||
"ref": "main",
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Everything-I-Know-About-Types/bergamot-elm.git"
|
||||
}
|
||||
},
|
||||
"blog-source": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1648508215,
|
||||
"narHash": "sha256-H8rF4vpzeNw6Pg/hMtF45UFSm/cHN9HIalDrz+mfpC8=",
|
||||
"ref": "master",
|
||||
"rev": "f044082fa53b72a5b8386e42a200ddb8072c7a90",
|
||||
"revCount": 560,
|
||||
"lastModified": 1744505804,
|
||||
"narHash": "sha256-lQtixsVcCSHSpkiYHqqvarxDiI7KekZog907SmUD2W0=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "7fbd4ea9f83bbb6cc28f069702112961d3cd0e24",
|
||||
"revCount": 920,
|
||||
"submodules": true,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Web-Projects/blog-static.git"
|
||||
@@ -18,32 +41,16 @@
|
||||
"url": "https://dev.danilafe.com/Web-Projects/blog-static.git"
|
||||
}
|
||||
},
|
||||
"blog-source-localized": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1599463261,
|
||||
"narHash": "sha256-n6e4uRiOsWuOL7DSzbuP9X8cZNLnKOD/2/eOT0aB+Io=",
|
||||
"ref": "localization",
|
||||
"rev": "0b5748cc5a19b5d1d78bfcfa58d4027cc10524dd",
|
||||
"revCount": 367,
|
||||
"submodules": true,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Web-Projects/blog-static.git"
|
||||
},
|
||||
"original": {
|
||||
"ref": "localization",
|
||||
"submodules": true,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Web-Projects/blog-static.git"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1648297722,
|
||||
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -53,12 +60,15 @@
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1648297722,
|
||||
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -68,12 +78,15 @@
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"inputs": {
|
||||
"systems": "systems_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1648297722,
|
||||
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -82,97 +95,150 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"katex-html": {
|
||||
"flake-utils_4": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"katex-server": "katex-server",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"systems": "systems_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1648445866,
|
||||
"narHash": "sha256-kLqnZXRxmlk3cSx8fA6dvrAVrqOGLzxboPnP5zQ7SQU=",
|
||||
"ref": "master",
|
||||
"rev": "dfc582d367ebda79649d339d1edc5476eb0cf954",
|
||||
"revCount": 13,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Nix-Configs/katex-html"
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Nix-Configs/katex-html"
|
||||
}
|
||||
},
|
||||
"katex-server": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1648445837,
|
||||
"narHash": "sha256-llpVUGpy4RQo33B48U3RIz0HBFf2Wqb4SoK1lbeqOjs=",
|
||||
"ref": "master",
|
||||
"rev": "2925bd0b2bc5d980eb7b8f79feac28b377a0de13",
|
||||
"revCount": 6,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Nix-Configs/katex-server"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Nix-Configs/katex-server"
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1648444094,
|
||||
"narHash": "sha256-2liapKh7WXPHELuzLvYK+464g4w9tr9DbNxGuz8XZ98=",
|
||||
"lastModified": 1766736597,
|
||||
"narHash": "sha256-BASnpCLodmgiVn0M1MU2Pqyoz0aHwar/0qLkp7CjvSQ=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "87c74b8120980461a9d4ce8f341551ce0fb50728",
|
||||
"rev": "f560ccec6b1116b22e6ed15f4c510997d99d5852",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-25.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"resume": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1648444094,
|
||||
"narHash": "sha256-2liapKh7WXPHELuzLvYK+464g4w9tr9DbNxGuz8XZ98=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "87c74b8120980461a9d4ce8f341551ce0fb50728",
|
||||
"type": "github"
|
||||
"lastModified": 1766794825,
|
||||
"narHash": "sha256-+Fabo0uQF9srEXdi9TB1wjB+PHaU9htXj/fjnvUFNAs=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "f22cb5b79580020079ba7223346e612b41eb7d42",
|
||||
"revCount": 74,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/DanilaFe/resume"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1648444094,
|
||||
"narHash": "sha256-2liapKh7WXPHELuzLvYK+464g4w9tr9DbNxGuz8XZ98=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "87c74b8120980461a9d4ce8f341551ce0fb50728",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/DanilaFe/resume"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"blog-source": "blog-source",
|
||||
"blog-source-localized": "blog-source-localized",
|
||||
"flake-utils": "flake-utils",
|
||||
"katex-html": "katex-html",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"resume": "resume",
|
||||
"web-files": "web-files"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_4": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"web-files": {
|
||||
"inputs": {
|
||||
"bergamot-elm": "bergamot-elm",
|
||||
"flake-utils": "flake-utils_4",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1766788330,
|
||||
"narHash": "sha256-7Dx1g0fM/glKCBzo2ZgIwXyp5ASyG/Y7S5OPcltb3Os=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "407b087a1d0042e04bbcc9333097decd9e776270",
|
||||
"revCount": 14,
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Nix-Configs/web-files.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://dev.danilafe.com/Nix-Configs/web-files.git"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
39
flake.nix
39
flake.nix
@@ -1,35 +1,32 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
katex-html.url = "git+https://dev.danilafe.com/Nix-Configs/katex-html";
|
||||
resume.url = "git+https://dev.danilafe.com/DanilaFe/resume";
|
||||
resume.inputs.nixpkgs.follows = "nixpkgs";
|
||||
blog-source = {
|
||||
flake = false;
|
||||
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
|
||||
type = "git";
|
||||
submodules = true;
|
||||
};
|
||||
blog-source-localized = {
|
||||
flake = false;
|
||||
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
|
||||
ref = "localization";
|
||||
type = "git";
|
||||
submodules = true;
|
||||
};
|
||||
web-files.url = "git+https://dev.danilafe.com/Nix-Configs/web-files.git";
|
||||
web-files.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, blog-source, blog-source-localized, nixpkgs, flake-utils, katex-html }:
|
||||
{
|
||||
buildersFor = system: import ./lib.nix {
|
||||
inherit blog-source blog-source-localized;
|
||||
outputs = { self, blog-source, nixpkgs, flake-utils, resume, web-files }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
lib = import ./lib.nix {
|
||||
inherit blog-source;
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
katex-html = katex-html.defaultPackage.${system};
|
||||
};
|
||||
nixosModule = (import ./module.nix);
|
||||
packages.x86_64-linux.blog-debug = (import ./lib.nix {
|
||||
inherit blog-source blog-source-localized;
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
katex-html = katex-html.defaultPackage."x86_64-linux";
|
||||
}).english { host = "danilafe.com"; };
|
||||
resume = resume.defaultPackage.${system};
|
||||
web-files = web-files.defaultPackage.${system};
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit lib;
|
||||
defaultPackage = lib.english { host = "danilafe.com"; };
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
53
gemset.nix
Normal file
53
gemset.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
duktape = {
|
||||
groups = ["default"];
|
||||
platforms = [];
|
||||
source = {
|
||||
remotes = ["https://rubygems.org"];
|
||||
sha256 = "1nrhvxbhflf2lrd8v4rphsf0lwg0lvfws2i0cpq8s0xxgh4lviia";
|
||||
type = "gem";
|
||||
};
|
||||
version = "2.7.0.0";
|
||||
};
|
||||
execjs = {
|
||||
groups = ["default"];
|
||||
platforms = [];
|
||||
source = {
|
||||
remotes = ["https://rubygems.org"];
|
||||
sha256 = "1yywajqlpjhrj1m43s3lfg3i4lkb6pxwccmwps7qw37ndmphdzg8";
|
||||
type = "gem";
|
||||
};
|
||||
version = "2.9.1";
|
||||
};
|
||||
mini_portile2 = {
|
||||
groups = ["default"];
|
||||
platforms = [];
|
||||
source = {
|
||||
remotes = ["https://rubygems.org"];
|
||||
sha256 = "0x8asxl83msn815lwmb2d7q5p29p7drhjv5va0byhk60v9n16iwf";
|
||||
type = "gem";
|
||||
};
|
||||
version = "2.8.8";
|
||||
};
|
||||
nokogiri = {
|
||||
dependencies = ["mini_portile2" "racc"];
|
||||
groups = ["default"];
|
||||
platforms = [];
|
||||
source = {
|
||||
remotes = ["https://rubygems.org"];
|
||||
sha256 = "0npx535cs8qc33n0lpbbwl0p9fi3a5bczn6ayqhxvknh9yqw77vb";
|
||||
type = "gem";
|
||||
};
|
||||
version = "1.18.3";
|
||||
};
|
||||
racc = {
|
||||
groups = ["default"];
|
||||
platforms = [];
|
||||
source = {
|
||||
remotes = ["https://rubygems.org"];
|
||||
sha256 = "0byn0c9nkahsl93y9ln5bysq4j31q8xkf2ws42swighxd4lnjzsa";
|
||||
type = "gem";
|
||||
};
|
||||
version = "1.8.1";
|
||||
};
|
||||
}
|
||||
87
lib.nix
87
lib.nix
@@ -1,25 +1,67 @@
|
||||
{ blog-source, blog-source-localized, pkgs, katex-html }:
|
||||
{ pkgs, blog-source, web-files, resume }:
|
||||
|
||||
with pkgs;
|
||||
with lib;
|
||||
|
||||
let
|
||||
protocol = ssl: if ssl then "https://" else "http://";
|
||||
gems = settings: bundlerEnv {
|
||||
inherit ruby;
|
||||
|
||||
name = "blog-static-flake";
|
||||
gemfile = "${settings.src}/Gemfile";
|
||||
lockfile = "${settings.src}/Gemfile.lock";
|
||||
gemset = ./gemset.nix;
|
||||
};
|
||||
|
||||
pythonEnv = python3.withPackages (python-pkgs: [
|
||||
python-pkgs.beautifulsoup4
|
||||
python-pkgs.lxml
|
||||
python-pkgs.fonttools
|
||||
python-pkgs.brotli
|
||||
]);
|
||||
|
||||
# --- Building Agda HTML ---
|
||||
agdaEnv = agda.withPackages [ agdaPackages.standard-library ];
|
||||
agdaHtml = settings:
|
||||
let
|
||||
# Create content-addresed versions of the scripts in the Nix store to
|
||||
# avoid throwing off memoization for unrelated changes.
|
||||
agdaBuildScript = builtins.toFile "build-agda-html.rb" (builtins.readFile "${settings.src}/build-agda-html.rb");
|
||||
submoduleDataFile = builtins.toFile "submodules.json" (builtins.readFile "${settings.src}/data/submodules.json");
|
||||
codeRoot = pkgs.lib.cleanSource "${settings.src}/code";
|
||||
agdaCommand = pkgs.lib.escapeShellArg "agda -l standard-library -i . ";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "blog-static-agda-html";
|
||||
buildInputs = [ ruby agdaEnv ];
|
||||
builder = builtins.toFile "builder.sh" "
|
||||
source $stdenv/setup
|
||||
mkdir -p code $out
|
||||
cp -r ${codeRoot}/* code/
|
||||
chmod -R u+w code
|
||||
ruby ${agdaBuildScript} --data-file=${submoduleDataFile} --target-dir=$out ${agdaCommand}
|
||||
";
|
||||
};
|
||||
|
||||
website = settings: stdenv.mkDerivation {
|
||||
inherit (settings) src ssl host;
|
||||
inherit resume ruby;
|
||||
name = "blog-static";
|
||||
version = settings.src.rev;
|
||||
urlSub =
|
||||
let
|
||||
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
|
||||
in
|
||||
with settings.replaceUrl; "s/${regexEscape from}/${regexEscape to}/g";
|
||||
version = settings.src.rev or "dirty";
|
||||
publicPath = settings.path;
|
||||
extraFlags = if settings.drafts then " -D " else "";
|
||||
hugoFlags = concatStringsSep " " (
|
||||
optionals settings.drafts (singleton "-D") ++
|
||||
[ "--baseURL=${protocol settings.ssl + settings.host}" ]
|
||||
);
|
||||
builder = ./build/builder.sh;
|
||||
webFiles = web-files;
|
||||
gems = gems settings;
|
||||
agdaHtml = agdaHtml settings;
|
||||
buildInputs = [
|
||||
hugo katex-html
|
||||
hugo ruby stork agdaEnv pythonEnv
|
||||
];
|
||||
};
|
||||
wrapHost = ssl: host: (if ssl then "https" else "http") + "://${host}";
|
||||
in
|
||||
{
|
||||
english = settings: website {
|
||||
@@ -28,20 +70,17 @@ in
|
||||
drafts = settings.drafts or false;
|
||||
src = blog-source;
|
||||
path = ".";
|
||||
replaceUrl = {
|
||||
from = "https://danilafe.com";
|
||||
to = wrapHost (settings.ssl or false) settings.host;
|
||||
};
|
||||
};
|
||||
russian = settings: website {
|
||||
inherit (settings) host;
|
||||
ssl = settings.ssl or false;
|
||||
drafts = settings.drafts or false;
|
||||
src = blog-source-localized;
|
||||
path = "ru";
|
||||
replaceUrl = {
|
||||
from = "https://ru.danilafe.com";
|
||||
to = wrapHost (settings.ssl or false) settings.host;
|
||||
};
|
||||
virtualHostFor = package:
|
||||
{
|
||||
"${package.host}" = mkMerge [
|
||||
{
|
||||
root = package;
|
||||
}
|
||||
(mkIf (package.ssl) {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
58
module.nix
58
module.nix
@@ -1,58 +0,0 @@
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.danilafe-blog;
|
||||
sslForSite = package: package.ssl;
|
||||
anySsl = any sslForSite cfg.sites;
|
||||
virtualHost = package:
|
||||
{
|
||||
virtualHosts."${package.host}" = mkMerge [
|
||||
{
|
||||
root = package;
|
||||
}
|
||||
(mkIf (sslForSite package) {
|
||||
addSSL = true;
|
||||
enableACME = true;
|
||||
acmeRoot = cfg.challengePath;
|
||||
})
|
||||
];
|
||||
};
|
||||
service = package:
|
||||
{
|
||||
# Workaround for new configuration setting all of /var to be readonly.
|
||||
# See https://github.com/NixOS/nixpkgs/issues/139310
|
||||
"acme-${package.host}".serviceConfig = {
|
||||
ReadWritePaths = [ cfg.challengePath ];
|
||||
};
|
||||
};
|
||||
virtualHosts = map virtualHost cfg.sites;
|
||||
services = map service (filter sslForSite cfg.sites);
|
||||
in
|
||||
{
|
||||
options.services.danilafe-blog = {
|
||||
enable = mkEnableOption "Daniel's blog service";
|
||||
sites = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = {};
|
||||
description = "List of versions of this blog that should be enabled.";
|
||||
};
|
||||
challengePath = mkOption {
|
||||
type = types.str;
|
||||
description = "The location for ACME challenges.";
|
||||
};
|
||||
};
|
||||
|
||||
config.services.nginx = mkIf cfg.enable (mkMerge (virtualHosts ++ [
|
||||
{
|
||||
# Always enable nginx.
|
||||
enable = true;
|
||||
recommendedGzipSettings = true;
|
||||
}
|
||||
]));
|
||||
config.systemd.services = mkIf cfg.enable (mkMerge services);
|
||||
config.security.acme = mkIf (cfg.enable && anySsl) {
|
||||
# If any site uses SSL, enable ACME and accept terms.
|
||||
defaults.email = "danila.fedorin@gmail.com";
|
||||
acceptTerms = true;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user