Bundle files from web-files at build time.

This commit is contained in:
Danila Fedorin 2023-11-30 07:09:28 +00:00
parent ab4b92d031
commit aebf198ca8
4 changed files with 162 additions and 13 deletions

View File

@ -8,8 +8,16 @@ cp -r $src/* .
# We'll generate some static files so make static writable
mkdir -p static && chmod -R u+w static
# We host some static files (KaTeX CSS in production) on
# static.danilafe.com. However, we can just bundle them here instead!
echo '[params]' >> config-urls.toml
echo 'katexCssUrl = "/katex/katex.min.css"' >> config-urls.toml
echo 'bergamotJsUrl = "/bergamot/bergamot.js"' >> config-urls.toml
echo 'katexExpressionJsUrl = "/katex-expression/katex-expression.esm.js"' >> config-urls.toml
cp -r $webFiles/* static/
# Build site with Hugo
hugo $hugoFlags --config=config.toml,config-gen.toml
hugo $hugoFlags --config=config.toml,config-urls.toml,config-gen.toml
# Create generated files
# Can't do submodules because nix flake inputs get their .git deleted
@ -18,7 +26,7 @@ stork build --input public/index.toml --output static/index.st # Search index
cp $resume/Resume-Danila-Fedorin.pdf static/Resume-Danila-Fedorin.pdf
# Static folder changed, re-run Hugo
hugo $hugoFlags --config=config.toml,config-gen.toml
hugo $hugoFlags --config=config.toml,config-urls.toml,config-gen.toml
# Output result
mkdir $out

View File

@ -1,13 +1,33 @@
{
"nodes": {
"bergamot-elm": {
"inputs": {
"flake-utils": "flake-utils_5",
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1701318122,
"narHash": "sha256-wOik1hcZ6xwTUQZmDo8cPB7tE0VoyQM99zUTjqB4xUI=",
"ref": "main",
"rev": "524796d74fbec2828bf3f8f3b7abd4c843d529b3",
"revCount": 33,
"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": 1681105957,
"narHash": "sha256-9cjA5X5ZP4FkT48L2kHoujyB9l4WRnagdo5Sa+mKxHY=",
"lastModified": 1701325754,
"narHash": "sha256-phVjnTWDQ4jPYBMg00dvvbLzSYTsFZkzxVeZgNo3fPU=",
"ref": "master",
"rev": "a71c0c4e74d881af8631b17947ebe4bcb5c4ce0e",
"revCount": 634,
"rev": "5041c90ac01a154cc1ad5a13c43629894fa61bbd",
"revCount": 664,
"submodules": true,
"type": "git",
"url": "https://dev.danilafe.com/Web-Projects/blog-static.git"
@ -78,6 +98,42 @@
"type": "github"
}
},
"flake-utils_5": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_6": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"katex-html": {
"inputs": {
"flake-utils": "flake-utils_2",
@ -178,17 +234,48 @@
"type": "github"
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1701068326,
"narHash": "sha256-vmMceA+q6hG1yrjb+MP8T0YFDQIrW3bl45e7z24IEts=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8cfef6986adfb599ba379ae53c9f5631ecd2fd9c",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_6": {
"locked": {
"lastModified": 1701319520,
"narHash": "sha256-xVghb4ELbEtJUdEmB4PR+sq/aoNP0VEcM6GczDh+Zss=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "db77de49336382a33b9490a88ba3fe483e2b605f",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"resume": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1676875551,
"narHash": "sha256-DIcIlMWh9exQIXISxgnS25egwIquyuZX+UqdTMJpJZA=",
"lastModified": 1691357458,
"narHash": "sha256-kFdV5FUPCW7xNS8xonzHb8MgVjwu0PR5rZNuAQQE7Yw=",
"ref": "master",
"rev": "36fcd6d66fe2031d7429f8d60d5f83d64fd94cca",
"revCount": 47,
"rev": "c756fd5efaeb7d4484d535cd2fe3038491fc2550",
"revCount": 57,
"type": "git",
"url": "https://dev.danilafe.com/DanilaFe/resume"
},
@ -203,7 +290,58 @@
"flake-utils": "flake-utils",
"katex-html": "katex-html",
"nixpkgs": "nixpkgs_3",
"resume": "resume"
"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"
}
},
"web-files": {
"inputs": {
"bergamot-elm": "bergamot-elm",
"flake-utils": "flake-utils_6",
"nixpkgs": "nixpkgs_6"
},
"locked": {
"lastModified": 1701324990,
"narHash": "sha256-8R8XiWVhdm3WOu/VxLxKfRYiVDiWMx72F3w0G4ALfFA=",
"ref": "master",
"rev": "0724cfe43cf9e4a6abadaac87174e6fecc391b2b",
"revCount": 4,
"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"
}
}
},

View File

@ -10,9 +10,10 @@
type = "git";
submodules = true;
};
web-files.url = "git+https://dev.danilafe.com/Nix-Configs/web-files.git";
};
outputs = { self, blog-source, nixpkgs, flake-utils, katex-html, resume }:
outputs = { self, blog-source, nixpkgs, flake-utils, katex-html, resume, web-files }:
flake-utils.lib.eachDefaultSystem (system:
let
lib = import ./lib.nix {
@ -20,6 +21,7 @@
pkgs = import nixpkgs { inherit system; };
katex-html = katex-html.defaultPackage.${system};
resume = resume.defaultPackage.${system};
web-files = web-files.defaultPackage.${system};
};
in
{

View File

@ -1,4 +1,4 @@
{ pkgs, blog-source, katex-html, resume }:
{ pkgs, blog-source, web-files, katex-html, resume }:
with pkgs;
with lib;
@ -16,6 +16,7 @@ let
[ "--baseURL=${protocol settings.ssl + settings.host}" ]
);
builder = ./build/builder.sh;
webFiles = web-files;
buildInputs = [
hugo ruby stork katex-html
];